cryptojs: How to generate AES passphrase

后端 未结 2 1607

I want to generate a 256bit password for my AES encryption. When I check the password after the encryption it is different from my initial password. What am I doing wrong? Or i

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-15 18:51

    I found the solution. You can define your own key using var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv });

    So my source code is:

    key=CryptoJS.enc.Hex.parse(Generate_key());
    iv=CryptoJS.enc.Hex.parse(Generate_key());
    var encrypted = CryptoJS.AES.encrypt("Message", key, { iv: iv });
    

提交回复
热议问题