gpt4 book ai didi

javascript - 无法使用 CryptoJS 解密密码

转载 作者:行者123 更新时间:2023-11-30 16:43:05 26 4
gpt4 key购买 nike

我正在尝试使用 CryptoJS 进行加密。加密似乎工作正常,但当我解密密码时,我没有得到初始明文密码。

这是我的 JavaScript 代码:

<script type="text/javascript">
var password = "";
function noSsl()
{
$(document).ready(function()
{
$("#dialog").dialog({ show: 'fade', hide: 'fade' });
});
}
function savePassword()
{
password = document.getElementById("ap").value;
alert("Initial password: " + password);
enPassword = CryptoJS.AES.encrypt(password, <?php echo '"'.$currentAdk.'"'; ?>);
$(document).ready(function()
{
$("#ap").slideToggle("slow");
$("#sp").slideToggle("slow");
$("#sp").remove();
});
alert("Encrypted: " + enPassword);
var decrypted = CryptoJS.AES.decrypt(enPassword, <?php echo '"'.$currentAdk.'"'; ?>)
alert("Decrypted: " + decrypted);
}
</script>

结果如下:

enter image description here

enter image description here

enter image description here

最佳答案

要使用 CryptoJS 获取解密的明文密码,您需要使用:

var decryptedPlaintextPassword = CryptoJS.AES.decrypt(enPassword, <?php echo '"'.$currentAdk.'"'; ?>).toString(CryptoJS.enc.Utf8);

关于javascript - 无法使用 CryptoJS 解密密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31646564/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com