如何使用CryptoJS AES两次使用AES加密

时间:2019-05-18 07:27:01

标签: javascript aes cryptojs

我尝试使用cryptojs加密两次,但没有任何回报,这就是我的代码

var defaultKey = "Part of the journy is the end. Whatever it takes";
var userKey = 'in this whole universe iron man is the best superhero';
var encryptMsg ='';

encryptMsg = CryptoJS.AES.encrypt(msg, defaultKey);
alert(encryptMsg);
encryptMsg = CryptoJS.AES.encrypt(encryptMsg , userKey );
alert(encryptMsg);

第一个警报显示加密的文本,但seconf警报不显示任何内容

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,我不知道这是正确的方法,但是这件事对我有用

var defaultKey = "Part of the journy is the end. Whatever it takes";
var userKey = 'in this whole universe iron man is the best superhero';
var encryptMsg ='';

encryptMsg = CryptoJS.AES.encrypt(msg, defaultKey);
alert(encryptMsg);
encryptMsg = CryptoJS.AES.encrypt(String(encryptMsg) , userKey );
alert(encryptMsg);

我使用String()