Home >Backend Development >PHP Tutorial >Encryption using sha1() function-php encryption technology
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('PHPER');//使用md5()iA数加密字符串PHPER php echo shal('PHPER');//使用sha 1()函数加密字符串PHPER ?>
The comparative effect of MD5 encryption operation and SHA encryption operation string is shown in the figure below.
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!