adrek Posted June 26, 2010 Share Posted June 26, 2010 Hi, Im trying to make an application that encrypts a string using the implementation of javascript and i need this string to be decrypted using the php mcrypt module. I know that client side encryption is not secure at all but unfortunately my script requires it. The problem that i am having is that i am getting two different outputs when using slowAES and mcrypt. I am using CBC mode. Can anyone help me out.? Thanks! this is how I cam calling slowAES. var cipher = slowAES.encrypt(cryptoHelpers.convertStringToByteArray("asdf"), 2, cryptoHelpers.toNumbers(stringToHex("1234567890987654")), 16, cryptoHelpers.toNumbers(stringToHex("1234567890987654"))); here is the PHP code function base16Encode($arg){ $ret=""; for($i=0;$i<strlen($arg);$i++){ $tmp=ord(substr($arg,$i,1)); $ret.=dechex($tmp); } return $ret; } $key="1234567890987654"; $transmitKey=base16Encode($key); $link="asdf"; $cp = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); @mcrypt_generic_init($cp, $key,$key); $enc = mcrypt_generic($cp, $link); mcrypt_generic_deinit($cp); mcrypt_module_close($cp); Link to comment https://forums.phpfreaks.com/topic/205905-encryption-in-javascriptdecryption-in-php/ Share on other sites More sharing options...
adrek Posted June 26, 2010 Author Share Posted June 26, 2010 I got this figured out. I used an easier script to implement based off of slow aes. its called ecmaScrypt if anyone is interested. http://www.josh-davis.org/ecmaScrypt Link to comment https://forums.phpfreaks.com/topic/205905-encryption-in-javascriptdecryption-in-php/#findComment-1077512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.