Greetings!

I am working on a web site in which there is a need to store the orders. Part of the order is some personal info which should not be stored in plain text (SS number). Basically what I have is a submission order form which I want to encrypt the input and store it on the server in a protected directory. The owner of the web site will connect to a protected admin page and retrieve the orders in a tabular form. They will then click on each order and it will retrieve that order, decrypt it , and then display it for them to print off. After which they have the option to delete the order off the server.

When I try to execute it I can encrypt the text, and save it to a data file, but when I retrieve the data file and send it through the decrypt function, it comes back in a smaller encrypted form.

I am using the same keys in both functions. And if I put the encrypt and decrypt functions on the same page it works perfectly. So I know there is something that must be passed to the decrypt function so that it can truly decrypt the string.

Below are the encrypt and decrypt functions of my code. The missing information is what is constructing the data to be encrypted and then rebuilding it to be displayed. I am new to using the encryption features of PHP, so if my code is way wrong please correct me. If anyone can help, I would really appreciate it.

Thanks in advance,
John

BEGIN ENCRYPT CODE*****************************
$key = "Not the real key";
$cryptdata = mcrypt_encrypt(MCRYPT_3DES,$key,$data,MCRYPT_MODE_ECB,"0");
$filename = "data/" . $stamp;
$file = fopen($filename,w);
fwrite($file,$cryptdata);
fclose($file);
print "$cryptdata";   
END ENCRYPT CODE*******************************

BEGIN DECRYPT CODE*****************************
$filename = $_GET["q"];
$getdata = file($fname);
$key = "Not the real key";
$decryptdata=mcrypt_decrypt(MCRYPT_3DES,$key,$getdata[0],MCRYPT_MODE_ECB,"0");
print "$decryptdata";
END DECRYPT CODE*******************************

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to