Tuesday, 13 August 2013

PHP Mycrpyt decrypt problems with bin2hex

PHP Mycrpyt decrypt problems with bin2hex

I'm quite new to encryption with PHP. How do I decrypt the output form the
following returned encryption?
$key = "123456";
$text = "hello";
$cipher_alg = MCRYPT_RIJNDAEL_128;
$encrypted_body = mcrypt_encrypt($cipher_alg, $key, $text ,
MCRYPT_MODE_CBC, $iv);
$encrypted_body_hex = bin2hex($encrypted_body);
$encrypted_body_hex = strtoupper($encrypted_body_hex);
I thought if i just worked backwards it would be ok (strtolower, hex2bin,
then feed it through mcrypt_decrypt) but im not having any luck.
I think i am getting lost with the bin2hex as hex2bin is not supported on
my version of PHP.
Any help would be great.
Thanks in advance

No comments:

Post a Comment