cryptoJS简单的加密和解密 [英] cryptoJS simple encryption and decryption

查看:333
本文介绍了cryptoJS简单的加密和解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么解密结果不正确?

why the decryption result is not right?

var encrypted = CryptoJS.AES.encrypt("faizan", "sp");
    alert(encrypted);
    var decrypted = CryptoJS.AES.decrypt(encrypted, "sp");
    alert(decrypted);





使用 https://code.google.com/p/crypto-js/ [ ^ ]

推荐答案

如果您通过链接阅读文档,您会看到从解密返回不是字符串。

尝试使用
If you read the documentation at the link you gave, you will see that the return from decrypt is NOT a string.
Try using
alert(decrypted.toString(CryptoJS.enc.Utf8));

就像例子一样。


这篇关于cryptoJS简单的加密和解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆