Hi all,
I'm in the process of writing a script that will accept credit cards
through a secure html form,
and then encrypt them using MCRYPT_RIJNDAEL_256 and store them in my mysql
database.
When I run the following code snippet, nothing is returned through the
server - the
connection is established, but the server appears to be hanged.
Through a process of
commenting and uncommenting lines, I've discovered that the decrypting
line is causing the
problem.
<?php
$ccno = '1111222233334444';
$key = 'a';
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_CBC),MCRYPT_RAND);
echo 'Original data: ' . $ccno . '<br/>';
$encrypted =
mcrypt_encrypt(MCRYPT_RIJNDAEL_256,$key,$ccno,MCRYPT_MODE_CBC,$iv);
echo 'Encrypted: ' . bin2hex ($encrypted) . '<br/>';
echo 'Encrypted base64: ' . base64_encode($encrypted) . '<br />';
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_CBC),MCRYPT_RAND);
$newccno =
mcrypt_decrypt(MCRYPT_RIJNDAEL_256,$key,$encrypted,MCRYPT_MODE_CBC,$iv);
echo 'Decrypted: ' . $newccno . '<br/>';
echo 'Decrypted trimmed: ' . trim($newccno) . '<br />';
?>
(in the above code block, if I comment out the mcrypt_decrypt line,
everything works fine)
Note - this *was* just installed on my webhost by my request - there
could have been an installation error. The files and instructions used
were the windows binaries at www.php.net/mcrypt . If you think this
question could be better answered on php-windows, please let me know
:)
Any suggestions? :)
Thanks!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php