Encrypting Password using md5() function | PHP Tutorial for Beginners

MD5():-
The MD5 message-digest algorithm is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. MD5 has been utilized in a wide variety of security applications, and is also commonly used to check data integrity.

In our case it calculet the md5 hash of given string. With the use of md5() you can make your login system more secure.

Here is the Syntax of MD5():-
$user_password=”987654″;
echo md5($user_password);

Output :- 6c44e5cd17f0019c64b042e4a745412a
It encrypt the string which we have provided.

Example – Login Page

This is example of login page with encrypted password. You have also encrypt password during signup process else user will not able to login.

$user_name=$_POST['user_name'];
$user_password=$_POST['user_password'];

// encrypting password

$encrypted_password=md5($user_password);
$sql=”SELECT * FROM $user_details WHERE username=’$user_name’ and password=’$encrypted_password’”;
$result=mysql_query($sql);

Hope this php tutorial is useful for you. Keep following Php Tutorial for Beginners for more help.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>