PHP md5()Functions
Examples
Calculate the MD5 hash of the string "Hello":
Run example »
Definition and Usage
The md5() function calculates the MD5 hash of a string.
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 an input message of arbitrary length and converts it into a 128-bit "fingerprint" or "message digest" value that represents the input, and the converted value is used as the result. The MD5 algorithm is primarily designed for digital signature applications; in such applications, larger files are compressed in a secure manner before encryption (the encryption process is accomplished by setting a private key under a public key in a cryptosystem such as RSA).
To calculate the MD5 hash of a file, use themd5_file()function.
The md5() function cannot handle arrays; it returns null for arrays.md5(a[])The result isnull。
Online MD5 test tool:MD5 Online Encryption Tool
Syntax
| Parameter | Description |
|---|---|
| string | Required. Specifies the string to be calculated. |
| raw | Optional. Specifies the hexadecimal or binary output format:
|
Technical Details
| Return value: | Returns the calculated MD5 hash on success, or FALSE on failure. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | In PHP 5.0,rawthe parameter became optional. |
More Examples
Example 1
Output the result of md5():
Run example »
Example 2
Output the result of md5() and test it:
Run example »
PHP String Reference Manual Other Extensions