Simple example of php MD5 function

WBOY
Release: 2016-07-25 08:57:03
Original
1092 people have browsed it
This article introduces an example of the md5 function in php5 for the reference of beginners.

In PHP, it is necessary to encrypt the user password and store it. This requirement can be achieved by using the md5 function.

Usage of MD5 function in PHP:

<?php 
$pswd1=md5("cenusdesign"); 
echo $pswd1; //运行结果为:fc60ec37d1c08d5b0fb67a8cd934d5ba 

$pswd2=md5("Cenusdesign"); 
echo $pswd2; //运行结果为:067577d9fc109c80538c81d6f02bd293 
?>
Copy after login

After md5 encryption, the original "cenusdesign" is converted into a set of 32-bit strings. Moreover, even if the case of one letter changes, this set of strings will change dramatically.

When doing the user registration process, it is recommended to first convert the password to MD5, and then convert the encrypted database. When the user logs in, the password is first converted to MD5, and then compared with the set of MD5-encrypted strings in the database. This is indeed a lot more secure for passwords.



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template