Example code for using MD5 function in PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:51:33
Original
826 people have browsed it

Generally speaking, a website that provides member registration must collect user passwords. How to save user passwords is a problem. Of course we cannot store passwords in clear text in the database, because in this case, ordinary administrators can view the user password, which is obviously very dangerous for users.

So how to solve this problem? We can adopt this strategy.

First, let’s introduce how to use the MD5 function in PHP:

Copy the code The code is as follows:

$pswd1=md5("cenusdesign");
echo $pswd1; //The running result is: fc60ec37d1c08d5b0fb67a8cd934d5ba

$pswd2=md5("Cenusdesign");
echo $pswd2; //The running result is: 067577d9fc109c80538c81d6f02bd293
?>


Obviously, after md5 encryption, the original "cenusdesign" was transformed into a set of 32-bit Strings, and even a single letter case change can drastically change this set of strings.

Cenus Design recommends that when registering a user, the password should first be converted to MD5, and then the encrypted database should be converted. 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. In this way, the password comparison operation can be completed without knowing the user's exact password.

Author: Sunec
Original Published by: Cenus Blog
All rights reserved. When reprinting, the author, original source and this statement must be indicated in the form of a link.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319127.htmlTechArticleGenerally speaking, a website that provides member registration must collect user passwords. How to save user passwords is a problem. . Of course we cannot store the password in clear text in the data...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!