Not a good idea, you might look at some form of public key encryption
where you encrypt the credit card information with the public key and
the merchant decrypts it with their private key that is not on the
server.

You generally do not want to store the information encrypted with mcrypt
because in order for your application to encrypt it it must know the key
and the IV, in order for an attacker to decypt it all they need is the
IV and key as well.

There is a PHP module named "GPG Extension" available at
http://www.sourceforge.net/projects/gpgext/, it uses the gpg made easy
library to enable PHP to do public key encryption without launching
command line programs (also insecure).

Basically look on google for information on storing credit card numbers,
it is not easy to do this securely and generally good advice is not to
do it.  

If you have your merchants going over an SSL connection (which you
should) you can write your own PHP session handler and use mcrypt to
encrypt the session information with a random key generated by your
script, since it is passed over SSL it is encrypted in transit, then
decrypt the session information and load it.  Encrypting your sessions
opens the possibility to store more sensitive information inside them.

I still do not recommend storing credit card information even with these
measures, it exposes you for liability should something bad happen.  

Take a look at authorize.net or verisign's credit card processing
services, or find out if other processing companies have the capability
to store credit card information.

Jason
On Thu, 2003-01-30 at 07:30, Mike Morton wrote:
> I want to use the mcrypt functions to encrypt credit card numbers for
> storage in a mysql database, which mycrypt does admirably:
> 
> $key = "this is a secret key";
> $input = "Let us meet at 9 o'clock at the secret place.";
> $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_RIJNDAEL_256,
> MCRYPT_MODE_CBC), MCRYPT_RAND);
> 
> $encrypted_data = base64_encode(@mcrypt_encrypt (MCRYPT_RIJNDAEL_256 , $key,
> $input, MCRYPT_MODE_CBC,$iv));
> 
> The trouble is - the key and the IV.  Both of these have to be available in
> the merchants administration for retrieval of the credit card, thus need to
> be stored somewhere - most likely on the server or in a database.  Here is
> the problem - if someone gets to the database and retrieves the encrypted
> credit card, the chances are that they are able to also retrieve the script
> that did the encryption, thus find out where the key and IV are stored,
> making it simple to decrypt the credit card for them.
> 
> The only solution that I can see is to use an asymetric encryption and have
> the merchant enter the decryption key at the time of credit card retrieval -
> but that is unrealistic for a User Interface point of view.
> 
> So - the only other thing that I can see to do is have a compiled program,
> bound to the server, that has the key compiled into the program.  I am not a
> C programmer - so this is also not exactly possible.
> 
> Does anyone else have any answers or has anyone else run into this?  Is this
> just a general problem with doing encryption through PHP as opposed to a
> compiled binary?  Can anyone suggest a solution to this problem?
> 
> Thanks :)
> 
> 
> 
> 
> --
> Cheers
> 
> Mike Morton
> 
> ****************************************************
> *
> *  E-Commerce for Small Business
> *  http://www.dxstorm.com
> *
> * DXSTORM.COM
> * 824 Winston Churchill Blvd,
> * Oakville, ON, CA L6J 7X2
> * Tel: 905-842-8262
> * Fax: 905-842-3255
> * Toll Free: 1-877-397-8676
> *
> ****************************************************
> 
> "Indeed, it would not be an exaggeration to describe the history of the
> computer industry for the past decade as a massive effort to keep up with
> Apple."
> - Byte Magazine
> 
> Given infinite time, 100 monkeys could type out the complete works of
> Shakespeare. Win 98 source code? Eight monkeys, five minutes.
> -- NullGrey 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


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

Reply via email to