Md5 is an algorithm designed to verify data integrity. Reported to be much more reliable than checksum and other commonly used methods. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem like RSA Data Security or PGP.
Md5 is built into php and it calculates the MD5 hash of str using the RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. The hash is a 32-character hexadecimal number. If the optional raw_output is set to TRUE, then the md5 digest is instead returned in raw binary format with a length of 16.
You can read the whole article here:
http://www.faqs.org/rfcs/rfc1321
The md5() function is very useful for Password encryption. Keep in mind that we can not Decrypt it.
The most simplest method to use md5() function PHP with MySQL is as follows:
Insert the record into the MySQL Database using a query like:
| Code: |
| $query = "INSERT INTO user VALUES ('DummyUser',md5('DummyPassword'))"; |
And then for matching the password use:
| Code: |
$password = md5($password);
$query = "SELECT * FROM user WHERE username='DummyUser' AND password='DummyPassword'"; |
In the above code you can use your Variables instead of DummyUser & DummyPassword.