PDA

View Full Version : MD5 Encryption


JohnBradshaw
Sun 12th Aug '01, 4:18pm
Hi

I heard that it is possible to encrypt the contents of fields in a MySQL database, can someone explain how to do that?

JamesUS
Mon 13th Aug '01, 4:39am
You generally use PHP's md5() function before you insert the data into the database. I'm sure MySQL has a built in function for this as well, but I'm not sure what it is called; try searching the mysql manual on m www.mysql.com.

thewitt
Mon 13th Aug '01, 6:15am
Remember that MD5 is also one-way, so you cannot decrypt what you encrypted...

-t

JohnBradshaw
Mon 13th Aug '01, 10:09am
Ahh, so what's the point then? :)

thewitt
Mon 13th Aug '01, 1:35pm
Asymmetric hashing algorythms are most often used for passwords. In these cases, you don't want to know what your user's actual password is, but you want your user to be able to come back and get access using that password.

The user enters his password, you MD5 encrypt it and store it in the database.

The user comes back, enters his password, you MD5 encrypt it again and compare it with what you stored in the database. If they match, your user knew his password.

Symmetric encryption allows you to encrypt and then decrypt the data, but is less secure than a one-way hash, since you need to store the key somewhere.

-t