Encrypting Password using md5() function

本文介绍如何使用MD5算法加密密码,并提供了一个登录验证的例子。通过MD5加密,可以提高密码的安全性,确保即使数据库被泄露,用户的原始密码也不会轻易暴露。
Syntax

$password="123456";

md5($password);

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.

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

echo $encrypt_password;

 

 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

$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);

You can learn to create login system here

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值