Home  >  Article  >  Backend Development  >  How to encrypt password with md5 in php

How to encrypt password with md5 in php

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-21 16:29:087022browse

How to encrypt password with md5 in php

How to encrypt password in php? I believe that many friends who have just come into contact with php will have such questions. Let me introduce to you how PHP encrypts passwords and introduces the MD5() function encryption.

md5() function introduction

md5() function calculates the MD5 hash of a string, using RSA data security, including the MD5 message digest algorithm.

The MD5 algorithm is primarily designed for digital signature applications; in this digital signature application, larger files will be encrypted (where the encryption process is performed under a cryptographic system [such as: RSA ] is done by setting the private key under the public key) before compressing in a secure manner.

md5() function syntax

md5(string,raw);

string: Specifies the string to be calculated and the required parameters.

raw: Specifies the hexadecimal or binary output format, you can choose to set the parameters, there are the following two output formats:

TRUE - original 16-character binary format;

FALSE - 32 character hexadecimal number, this is the default value.

Related recommendations: "php tutorial"

md5() encryption is an irreversible encryption method. Let's take a look at an example:

$password = '123456';
echo md5($password);

This will encrypt the password "123456" into "e10adc3949ba59abbe56e057f20f883e", which will be difficult to crack.

md5() function example

Let’s take a look at an example of how PHP uses md5() encryption to verify information



Hello world!";
  exit;
  }
?>
  

Running results:

How to encrypt password with md5 in php

We can use it together with the database to call the user name and password in the database for comparison and verification to check the information for user login and other operations.

The above is the detailed content of How to encrypt password with md5 in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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