小编Yar*_*ron的帖子

cryptojs:如何生成AES密码

我想为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;
}
Run Code Online (Sandbox Code Playgroud)

输出是ie

0b05308c9a00f07044416bad7a51bacd282fc5c0c999551a4ff15c302b268b20 4df875993770411044fb35953166ee7833c32ca0741e9fec091dfa10138039e8

这是正常的还是我在这里做错了什么?感谢帮助!

encryption passwords aes cryptojs

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

aes ×1

cryptojs ×1

encryption ×1

passwords ×1