Encrypting Password Using md5() Function

This turorial will teach you that how to make your login system more secure. We will use md5(); function for this.


Syntax
{code type=codetype}

$pwd="123456";

md5($pwd);
{/code}

Use md5(); to encrypts password to make it more secure

Overview

Look at these two databases, it’s the same person and same info, the first one we don’t encrypt his password but the second one we encrypted his password

when you encryte "john856" using this code, you’ll see this result
"ad65d5054042fda44ba3fdc97cee80c6" This is not a random result, everytime you encrypt the same password you will get the same result.

{code type=codetype}
$pwd="john856";
$encrypt_pwd=md5($pwd);

echo $encrypt_pwd;

{/code}

Example – Login

This is an example Login with encrypted password but don’t forget to encrypt password and insert into database in sign up process.

// username and password sent from form
{code type=codetype}
$tpuser=$_POST[‘user’];
$tppass=$_POST[‘pass’];

// encrypt password
$encrypted_pwd=md5($tppass);

$sql="SELECT * FROM $tbl_name WHERE username=’$tpuser’ and password=’$encrypted_pwd’";
$result=mysql_query($sql);

{/code}

Comments
  1. Wijdan Rohail Reply
  2. Tutorial Lounge Reply
  3. BandonRandon Reply
  4. md5pass Reply
  5. livelybrowsers Reply

Leave a Reply

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