MD5() encryption in PHP

MD5() encryption in PHP
MD5() encryption in PHP

MD5() encryption in PHP
Part – 1



-In this Topic we are going to learn about the MD5() encryption.
-We are going to generate a hash code using md5() encryption.
-MD5( ) function takes the input string and encrypts the string and produces the hash output for the given input.
md5 (string, raw-output);

string – The string to be encrypted.
raw_output – 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.
-By default raw_output is set to FALSE, and then md5 returns a raw binary format with a length of 32.

Let us consider the following program,
Here we are declaring a string and giving it to md5() function.
$string =’Naveen’;
$enrypt = md5($string);
echo $encrypt;



-Here we are giving the string as ‘Naveen’, this string is encrypted to hash.
-This hash cannot be decrypted back. It is so difficult to find the decryption of the hash.
-It is good for the passwords to get them encrypted using md5() function.

-Whenever we have authentication details to have access the web pages then we need to have our Login details to be saved in a database.
-When we save the passwords in the database as it is, then there is a chance to know the Login details to others who access the database.
-So if you save your passwords with encrypted manner then even if other users trying to see your password then they cannot understand your password if you saved the password in an encrypted manner.
-The password encryption will be more protective and will have strong security.

-While saving the passwords we need to save them after encrypting.
-While accessing them we cannot access directly because the password is not encrypted.
-So we need to access the password after the entered password is encrypted.
-We will see an example for accessing the password in next part of this topic.



Leave a Reply