MD5 () function

Source: Internet
Author: User
Tags md5 hash
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.