我对加密和最佳实践完全陌生,但我会尽力去理解细微差别。我最后拼凑了以下“有效”的解决方案,但我很欣赏有关这是否是处理加密/解密的正确方法的反馈。我正在使用PHP 7。
import {Component} from 'angular2/core';
import {OnInit} from 'angular2/core';
@Component(
{
selector: 'puzzle',
template: `
<section class="combination">
I: {{ switch1Number }}<br>
II: {{ switch2Number }}<br>
III: {{ switch3Number }}<br>
IV: {{ switch4Number }}
</section>
`
})
export class PuzzleComponent implements OnInit {
switch1Number = Number;
switch2Number = Number;
switch3Number = Number;
switch4Number = Number;
ngOnInit() {
// Math.randon gives a random decimal value between 0 & 1.
// Math..round rounds it to 0 or 1
this.switch1Number = Math.round(Math.random());
this.switch2Number = Math.round(Math.random());
this.switch3Number = Math.round(Math.random());
this.switch4Number = Math.round(Math.random());
console.log(this.switch1Number, this.switch2Number, this.switch3Number, this.switch4Number);
}
}
建设性反馈将受到赞赏,以便我和其他人可以从我们正在阅读和做的事情中学习。
(在信用到期时给予信贷)
随机字符串生成:https://paragonie.com/blog/2015/07/how-safely-generate-random-strings-and-integers-in-php
实施openssl_encrypt:http://thefsb.tumblr.com/post/110749271235/using-opensslendecrypt-in-php-instead-of
谢天谢地!