ArticleDirectory
- Syntax
- Example 1
- Example 2
MD5 () function calculates the MD5 hash of a string.
The MD5 () function uses RSA Data Security, including MD5 packet excerptAlgorithm.
If the calculation succeeds, the calculated MD5 hash is returned. If the calculation fails, false is returned.
Syntax
MD5 (string, raw)
Parameters |
Description |
String |
Required. Specifies the string to be calculated. |
Charlist |
Optional. The hexadecimal or binary output format is required:
- True-original 16-character binary format
- False-default. 32-character hexadecimal number
Note: this parameter is added in PHP 5.0. |
Example 1
<? PHP $ STR = "hello"; echoMD5 ($ Str)
;?>
Output:
8b1a9953c4611296a827abf8c47804d7
Example 2
<? PHP $ STR = "hello"; echoMD5 ($ Str)
; If (MD5 ($ Str)
= '8b1a9953c4611296a827abf8c47804d7 ') {echo "<br/> Hello world! "; Exit ;}?>
Output:
8b1a9953c4611296a827abf8c47804d7hello world!