在 JavaScript 中解密 PHP AES/CBC 加密字符串
我真的很疯狂地试图用以下代码片段在 JavaScript 中解密用 PHP 加密的字符串:
function myencrypt($str) {
$iv = '1234567890abcdef';
$key = 'abcdef1234567890';
$td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
mcrypt_generic_init($td, $key, $iv);
$encrypted = mcrypt_generic($td, $str);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return bin2hex($encrypted);
}
我尝试过 SlowAES、gibberish-aes 和其他一些可用的 JS 库,但总是无法正确解密单个字符串。
我也在 SO 中进行了广泛的搜索,但无法找到适合我的情况的解决方案。
任何指向正确解决方案的指针都将受到欢迎!
谢谢, 亚历山德罗
I'm getting literally crazy trying to decrypt in JavaScript a string encrypted in PHP with the following code snippet:
function myencrypt($str) {
$iv = '1234567890abcdef';
$key = 'abcdef1234567890';
$td = mcrypt_module_open('rijndael-128', '', 'cbc', $iv);
mcrypt_generic_init($td, $key, $iv);
$encrypted = mcrypt_generic($td, $str);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return bin2hex($encrypted);
}
I've tried slowAES, gibberish-aes and some other available JS libraries, but always failed to correctly decrypt a single string.
I've also extensively searched in SO, but was unable to find a solution applicable to my situation.
Any pointer toward the right solution would be more than welcome!
Thanks,
Alessandro
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过 crypto-js 库?抱歉,但我不确定
mcrypt_module_open('rijndael-128'
到底做了什么,但如果它只使用 CBC 它应该可以工作have you tried the crypto-js library? Sorry but i'm not sure what
mcrypt_module_open('rijndael-128'
does exactly but if it just uses CBC it should work