JavaScript中的AES匹配PHP的mcrypt [英] AES in JavaScript that matches PHP's mcrypt

查看:183
本文介绍了JavaScript中的AES匹配PHP的mcrypt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么JavaScript库,让你加密和解密256位AES的方式,你用PHP做mcrypt的方式(当然得到相同的结果)?我想给它一个可变长度的消息和一个32字符的键。我发现所有的库都需要固定长度的明文块和字节数组的键。

Is there any JavaScript libs that lets you encrypt and decrypt 256 bit AES the way you do it with mcrypt in PHP (and get the same result of course)? I want to give it a variable-length message and a 32 chars key. All libs I find wants fixed-length blocks of cleartext and byte-arrays of keys.

这是在PHP中的做法:

This is how it's done in PHP:

$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
echo mcrypt_encrypt(MCRYPT_RIJNDAEL_256, "32 CHARS THAT REPRESENT MY KEY!!", "hello", MCRYPT_MODE_ECB, $iv);    


推荐答案

是的!我做的(开始的)mcrypt的javascript。它没有完全相同的接口,但它是类似的。 https://code.google.com/p/js-mcrypt/

Yes! I made (the beginnings of) mcrypt for javascript. It doesn't have the exact same interface but it's similar. https://code.google.com/p/js-mcrypt/

这篇关于JavaScript中的AES匹配PHP的mcrypt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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