Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AES in JavaScript that matches PHP's mcrypt

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.

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);    
like image 535
Martin Avatar asked Aug 26 '10 16:08

Martin


1 Answers

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/

like image 94
Rick Avatar answered Oct 19 '22 03:10

Rick