Common hash encryption functions in php $ hash_list = hash_algos (); // return the registered hash rule list
Print_r ($ hash_list); // display the result
Create a file to calculate the hash value: file_put_contents('example.txt ', 'The quick brown fox jumped over the lazy dog .');
Output hash value information:
Echo hash_file ('md5', 'example.txt ');
$ Str = "the quick brown fox jumped over the lazy dog."; // define a string
Echo hash ('ripmd160 ', $ str); // Generate a hash value
$ Ctx = hash_init ('md5'); // initialize a hash value.
Hash_update ($ ctx, 'The quick brown Fox'); // injects data into the hash value
Hash_update ($ ctx, 'jumped over the lazy dog. '); // injects data into the hash value
Echo hash_final ($ ctx); // output the final result
$ Str = "the quick brown fox jumped over the lazy dog."; // define a string
$ Fp = tmpfile (); // create a temporary file
Fwrite ($ fp, $ str); // write a string to a temporary file
Rewind ($ fp); // The position of the inverted file pointer
$ Ctx = hash_init ('md5'); // initialize a hash value.
Hash_update_stream ($ ctx, $ fp); // injects data into the data stream
Echo hash_final ($ ctx); // output the result
$ Str = "the quick brown fox jumped over the lazy dog."; // define a string
Echo hash_hmac ('ripmd160 ', $ str, 'secret'); // Generate the hash value containing the key
/* Create a file and write the string to it */
$ File = "example.txt"; // defines the file name.
$ Str = "the quick brown fox jumped over the lazy dog."; // define a string
File_put_contents ($ file, $ str); // write a string to the file.
Echo hash_hmac_file ('md5', $ file, 'secret'); // Generate a hash value containing the key
$ Ctx = hash_init ('sha1'); // defines the string
Hash_update ($ ctx, 'The quick brown fox jumped over the lazy dog. '); // injects data into the hash value
Echo hash_final ($ ctx); // output the result
// Open source code phpfensi.com