2 way encryption...
Posted: Tue Oct 07, 2008 6:58 am
Hi Guys,
I've got a website thats holding pretty sensative information in a mysql db. The problem being that the data will need to be decrypted and read, by a human, at some point in the future, so the data needs to be able to be decrypted quickly and on-the-fly back into it's original context.
I've been looking at mcrypt and read some interesting stuff, I just wondered if anybody knew a way to get 128 (or even 256) bit 2way encryption with PHP.
The following gave me interesting results...
The result was: Decrypted string: sensative data??
WITH the two symbols on the end, so obviously, we can't be doing with that.
If anybody can help me it would be much appriciated.
Cheers for your help
I've got a website thats holding pretty sensative information in a mysql db. The problem being that the data will need to be decrypted and read, by a human, at some point in the future, so the data needs to be able to be decrypted quickly and on-the-fly back into it's original context.
I've been looking at mcrypt and read some interesting stuff, I just wondered if anybody knew a way to get 128 (or even 256) bit 2way encryption with PHP.
The following gave me interesting results...
Code: Select all
$string = 'sensative data';
$key = 'encryption key';
$cipher_alg = MCRYPT_RIJNDAEL_128;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg, MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_CBC, $iv);
$decrypted_string = mcrypt_decrypt($cipher_alg, $key, $encrypted_string, MCRYPT_MODE_CBC, $iv);
echo 'Decrypted string: ' . $decrypted_string;
WITH the two symbols on the end, so obviously, we can't be doing with that.
If anybody can help me it would be much appriciated.
Cheers for your help