Encrypting CreditCard Numbers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Encrypting CreditCard Numbers

Post by daven »

I am setting up a ShoppingCart application, and I need to encrypt the credit card numbers (I have a thing about sticking plain-text CCs in a database).
Unfortunately, I do not have the MCrypt functions installed, nor can I get them (I do not have control over the server). Any ideas?
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

I suspect the answer is no, but do you have the openssl functions installed? While harder to use than mcrypt, the library does support a full suite of crypto-tools.

Does your database support encryption at the database level? How secure is your database?

What is your threat model? Are you worried about exposing CC# to local or remote users, etc?
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

I do have OpenSSL, since I beat the server admin until he gave me it. I did not know about the crypto tools in the library. I'll check them out.

Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if you're using mysql and the version does support it you may use some of the functions listed at http://www.mysql.com/doc/en/Miscellaneo ... tions.html
there are several encode/decode and encrypt/decrypt functions.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

None of the mysql crypto options are providing any type of security if you are using a shared web hosting service, even if running suExec with private files I would never ever consider anything that can be decryprypted at the server as safe....

Unless you have a dedicated (or preferably two) and fairly hardened server(s), your only secure option is a public/private key type encryption, such as GnuPG, PGP or S/Mime (or whatever x509 stuff the S/mime stuff uses, I am not sure on the right terms there, OpenSSL supports S/Mime).
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

how would you store the private part of an public/private key mechanism more secure then the passphrase needed e.g. for mysql's aes_decrypt?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

sorry about that, I didn't think of the new stuff in MySQL version 4, but as most web hosts still use version 3.23, and 4 is still not production-stable.. But yeah, that is right, MySQL 4 offers full DES,SHA, AES and others support..

And your are right that there would be no difference in how to store the keys, myself I would never store that in any format on a shared-hosting server, nor any server with user login accounts and such..
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

of course you need a trustworthy host for that kind of action and I'm glad not to have to make that decision (lucky me).
And, yeah, msql4 support ist thinspread and even about the reliability of the new version I haven't found much (useful)
Post Reply