crypto-js,AES.decrypt相同的key和text,每次解密结果不同

 你是不是这样写的?使用key 对text进行AES解密,每次text和key是相同的,但是结果不同,一头雾水

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

解决办法:把key 用CryptoJS.enc.Utf8.parse 解析一下即可 

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

参考地址

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

猜你喜欢

转载自blog.csdn.net/qq_17335549/article/details/130617298