PHP commonly used hash encryption function, Phphash encryption
In this paper, we describe the commonly used hash encryption function in PHP. Share to everyone for your reference. The specific analysis is as follows:
Copy the Code code as follows: $hash _list=hash_algos (); Returns the list of registered hash rules
Print_r ($hash _list); Show results
Create a file to calculate the hash value: file_put_contents (' example.txt ', ' The quick brown fox jumped over the the lazy Dog. ');
Output hash Value information:
Copy CodeThe code is as follows: Echo hash_file (' MD5 ', ' example.txt ');
$str = "The quick brown fox jumped over the lazy dog."; Defining strings
echo Hash (' ripemd160 ', $str); Generate hash value
$ctx =hash_init (' MD5 '); Initialize a hash value
Hash_update ($ctx, ' The quick brown fox '); Pouring data into a hash value
Hash_update ($ctx, ' jumped over the lazy dog '); Pouring data into a hash value
echo hash_final ($CTX); Output the final result
$str = "The quick brown fox jumped over the lazy dog."; Defining strings
$FP =tmpfile (); Create a temporary file
Fwrite ($fp, $STR); Writes a string to a temporary file
Rewind ($FP); Rewind the position of the file pointer
$ctx =hash_init (' MD5 '); Initialize a hash value
Hash_update_stream ($ctx, $fp); Pouring data into the data stream
echo hash_final ($CTX); Output results
$str = "The quick brown fox jumped over the lazy dog."; Defining strings
echo Hash_hmac (' ripemd160 ', $str, ' secret '); Generate a hash value that contains the key
/* Create a file and write the string to it */
$file = "Example.txt"; Define file name
$str = "The quick brown fox jumped over the lazy dog."; Defining strings
File_put_contents ($file, $STR); Writing a string to a file
echo hash_hmac_file (' MD5 ', $file, ' secret '); Generate a hash value that contains the key
$ctx =hash_init (' SHA1 '); Defining strings
Hash_update ($ctx, ' The quick brown fox jumped over the the lazy Dog. '); Pouring data into the hash value
echo hash_final ($CTX); Output results
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/916060.html www.bkjia.com true http://www.bkjia.com/PHPjc/916060.html techarticle PHP commonly used hash encryption function, Phphash encryption This article describes the PHP commonly used hash encryption function. Share to everyone for your reference. The specific analysis is as follows: Copy code code as follows: $hash _l ...