Home >Backend Development >PHP Problem >How to use md5() function in PHP
In PHP, the md5() function is used to calculate the MD5 hash of a string, that is, to encrypt the string. The syntax is "md5(string)"; the parameter string is required, indicating that it requires Computed string.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
md5() function calculates strings MD5 hash.
The md5() function uses RSA data security, including the MD5 message digest algorithm.
Explanation from RFC 1321 - MD5 message digest algorithm: The MD5 message digest algorithm takes information of any length as an input value and converts it into a 128-bit length "fingerprint information" or "message" Summary" value to represent this input value, and the converted value as the result. The MD5 algorithm is primarily designed for digital signature applications where larger files are encrypted using a public key in a cryptographic system such as RSA. (done by setting a private key) before compressing in a secure manner.
Grammar
md5(string,raw)
Example
<!DOCTYPE html> <html> <body> <?php $str = "Shanghai"; echo md5($str); ?> </body> </html>
Result:
Recommended: "2021 PHP interview questions summary (collection)" "php video tutorial》
The above is the detailed content of How to use md5() function in PHP. For more information, please follow other related articles on the PHP Chinese website!