crypto-js, AES.decrypt the same key and text, each decryption result is different

 Did you write like this? Use key to perform AES decryption on text, every time text and key are the same, but the result is different, confused

// 问题: 使用key 对text进行AES解密,每次text和key是相同的,但是结果不同
const res = AES.decrypt(text, key)

Solution: parse the key with CryptoJS.enc.Utf8.parse 

// 把key 用CryptoJS.enc.Utf8.parse 解析一下即可
const res = AES.decrypt(text, CryptoJS.enc.Utf8.parse(key))

reference address

Every time New Encrypted string Generate using AES · Issue #151 · brix/crypto-js · GitHubHello, I'm using crypto-js library with Node.js Encryption/Decryption `(String/ Stringify object). Issue is that when i try to Encrypt any string then every moment i get different different encrypted strings But when i Decrypt this all t...https://github.com/brix/crypto-js/issues/151

 

Guess you like

Origin blog.csdn.net/qq_17335549/article/details/130617298