Greetings all, first time poster here

I've recently gotten a job doing php and its been going extreamly well. I've written tons of code and they are loveing my work, however my employers just dropped a new subset of the project on me. A bunch of user details (this system will have a large number of users in the end) such as Social Security/Insureance #'s, Pay Rates, etc have to be stored in the database for the Payroll department to use. Now thats no problem, but these are sensitive details that the other employees shouldn't see so we want to store this data in the database (MySQL) encrypted. So I've been testing encrypting and decrypting with mcrypt.
Heres the code I have.
Encrypting -
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$unenc_data = "$ssn,$pay,$time,$w4,$hours";
$key = $passwd;
$encrypted = mcrypt_cbc(MCRYPT_DES, $key, $unenc_data, MCRYPT_ENCRYPT);
[/code]
Decrypting -
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$unencrypted = mcrypt_cbc(MCRYPT_DES, $passwd, $enc_data, MCRYPT_DECRYPT);
[/code]

$passwd and $enc_data are passed to the script via a POST from an HTML form. Now the problem I have is this, it seem to encrypt without a problem..but it dosan't decrypt. I just end up with a bunch of jibberish and once and a while a small part of the actuall data...its really quite frustrating.

Any insite you might be able to shed would be great. Thanks




------------------
- theFinn
http://www.totalgeek.org