Commonly used hash encryption functions in php

高洛峰
Release: 2016-11-29 13:34:47
Original
1365 people have browsed it

$hash_list=hash_algos(); //Return the registered hash rule list

print_r($hash_list); //Display the results

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 string

echo hash('ripemd160',$str); //Generate hash value

$ctx=hash_init('md5'); //Initialize a hash value

hash_update($ctx,'the quick brown fox'); //Pour data into the hash value

hash_update($ctx,'jumped over the lazy dog.'); //Pour data into the hash value

echo hash_final ($ctx);                   // Output the final result

 

$str="the quick brown fox jumped over the lazy dog.";         // Define the string

$fp=tmpfile();                               File ifwrite ($ FP, $ STR); // Write the string into temporary files

rewind ($ fp); // back to the position of the file pointer

$ ctx = hash_init ('md5'); //Initialize a hash value

hash_update_stream($ctx,$fp); brown fox jumped over the lazy dog."; //Define string

echo hash_hmac('ripemd160',$str,'secret'); //Generate a hash value containing the key

/*Create a file And write the string into it */

$file="example.txt"; //Define the file name

$str=" the quick brown fox jumped over the lazy dog."; //Define the 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'); //Define the string

hash_update($ctx,'the quick brown fox jumped over the lazy dog.'); //Pour data into the hash value

echo hash_final($ ctx); //Output results

//Open source code phpfensi.com

Related labels:
php
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!