我想为我的 AES 加密生成一个 256 位密码。当我在加密后检查密码时,它与我的初始密码不同。我究竟做错了什么?还是有一些我不知道的安全机制?
我的代码:
password=Generate_key();
var encrypted = CryptoJS.AES.encrypt("Message", password);
//Those two should be the same
document.write(password+"<br>");
document.write(encrypted.key);
function Generate_key() {
var key = "";
var hex = "0123456789abcdef";
for (i = 0; i < 64; i++) {
key += hex.charAt(Math.floor(Math.random() * 16));
//Initially this was charAt(chance.integer({min: 0, max: 15}));
}
return key;
}
输出是即
0b05308c9a00f07044416bad7a51bacd282fc5c0c999551a4ff15c302b268b20 4df875993770411044fb35953166ee7833c32ca0741e9fec091dfa10138039e8
这是正常的还是我在这里做错了什么?感谢帮助!