Thursday 16 May 2013

Episode 22: Password Encryption in PHP



In this tutorial, we are trying to encrypt our password using PHP.

At first we need a form for input our password and we create form in HTML is very easily and passing the form value to the PHP script with the POST or GET method.

Then stored this value in a variable like this
          $pass = $_POST[‘password’]

Now we can encrypted our password is very easily. PHP provides a powerful function for encryption is md5(). This function converts any length data to 32 character long encrypted data. The process is

          $en_pass = md5($pass);

If you use this function for your login or sing up activity then store this value in database. When you build an login procedure then you need do this again because the encrypted form is store in your database table and must be to match the value neither  you can’t login.

So it is very simple and easy to encrypt our data using this powerful function of PHP.


Written by ‘Shojib’

No comments:

Post a Comment