Saturday, March 29, 2008

Easy Use MD5(function)

Many programers have use MD5 now. Why MD5 ? Because MD5 is easy to use and its powerful. I mean, if you have using MD5 you are in the good step to make your script/program more secure.

So here the Syntax
$password="123456";
md5($password);
Use md5(); to encrypts password to make it more secure
You may look at images that i have shown to you at the below. On the first line, I dont made some encrytion. But i have to do in second line.



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.

$password="john856";
$encrypt_password=md5($password);

echo $encrypt_password;



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
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// encrypt password
$encrypted_mypassword=md5($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);