Home > Backend Development > PHP Tutorial > Encryption using sha1() function-php encryption technology

Encryption using sha1() function-php encryption technology

PHPz
Release: 2023-03-07 08:58:02
Original
2539 people have browsed it

The SHA algorithm in php encryption technology is similar to MD5. The full name of SHA is Secure Hash Algorithm (Secure Hash Algorithm). The sha1() function provided by PHP uses the SHA algorithm. The syntax of the function is as follows:

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

The function returns a 40-digit hexadecimal number. If the parameter raw_output is true, it returns a 20-digit binary number.

The default raw_output is false.

Note:

The 1 after sha is 1 in Arabic numerals (1.2.3), It is not the letter 1 (L), readers must pay attention.

Example of using sha1() function for encryption:

This example performs encryption on a string separately MD5 and SHA encryption operations. The example code is as follows:

<?
php echo md5(&#39;PHPER&#39;);//使用md5()iA数加密字符串PHPER
php echo shal(&#39;PHPER&#39;);//使用sha 1()函数加密字符串PHPER
?>
Copy after login

The comparative effect of MD5 encryption operation and SHA encryption operation string is shown in the figure below.

Encryption using sha1() function-php encryption technology


The above is the detailed content of Encryption using sha1() function-php encryption technology. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template