Why are these strange characters appearing in mcrypt?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2009-06-22T09:11:52Z
Indexed on
2010/04/06
15:33 UTC
Read the original article
Hit count: 517
I Encrypt and Decrypt successfully, but when I decrypt the value, appears strange characters at the final of string "???":
The initial $_POST['value']
do not have any blank space or any strange character
Any idea to solve this?
Encrypt with this:
$key='my key';
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$id = mcrypt_generic($td, $_POST['value']);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
Decrypt with this:
$key='my key';
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$id = mdecrypt_generic($td, $_COOKIE['value']);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
© Stack Overflow or respective owner