Hello! Ok, I've gotten mcrypt_encrypt working, but am having a problem with mcrypt_decrypt and was wondering if someone here could possibly give me a hand...
So, i'm encoding the information with the following code -
$key = "this is secret";
$td = mcrypt_module_open('tripledes', '', 'cfb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
mcrypt_generic_init($td, $key, $iv);
$encd=mcrypt_generic($td, $number);
mcrypt_generic_end($td);
This encrypts things just fine - I certainly can't read it, so I'm happy about it. The decrypt, on the other hand, is not throwing any errors, it's just not unencrypting anything. That code is as follows-
$size = mcrypt_get_iv_size (MCRYPT_TRIPLEDES, MCRYPT_MODE_CFB);
$iv = mcrypt_create_iv ($size, MCRYPT_RAND);
$key = "this is a secret now";
$unencd=mcrypt_decrypt("tripledes", $key, $b->CreditCardNumber, 'cfb', $iv);
This is just flat-out not working. The credit card number I get back is still encrypted.
Anybody got any ideas on what exactly I'm doing wrong here? I've read the page in the manual on mcrypt_decrypt, but it's just not getting through - it's getting late and I haven't had nearly as much coffee as I should be having, so if it's simple, please feel free to smack me upside the head and point me in the right direction.