Use the sha1 () function for encryption-php encryption technology

Source: Internet
Author: User
SHA algorithms are similar to MD5 in php encryption technology. SHA is called SecureHashAlgorithm (Secure Hash Algorithm). The sha1 () function provided by PHP uses SHA algorithm. SHA algorithm is similar to MD5 in php encryption technology. SHA is called Secure Hash Algorithm (Secure Hash Algorithm). The sha1 () function provided by PHP uses the SHA Algorithm. the Function syntax is as follows:

String sha 1 (string str [, bool raw_output])

The function returns a 40-bit hexadecimal number. if the raw_output parameter is true, a 20-bit binary number is returned.

The default value of raw_output is false.

Note:

Sha is followed by 1 in Arabic numerals (1.2.3) rather than 1 (L.

Example of using the sha1 () function for encryption:

In this example, MD5 and SHA encryption operations are performed on a string respectively. the instance code is as follows:

 

Figure shows the contrast effect between MD5 encryption and SHA encryption.

The above is the details about encryption using the sha1 () function-php encryption technology. For more information, see other related articles in the first PHP community!

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.