$hash_list=hash_algos(); //返回注册的hash规则列表
print_r($hash_list); //显示结果
创建文件以计算哈希值:file_put_contents('example.txt', 'the quick brown fox jumped over the lazy dog.');
输出哈希值信息:
- echo hash_file('md5', 'example.txt');
-
- $str="the quick brown fox jumped over the lazy dog.";
- echo hash('ripemd160',$str);
-
- $ctx=hash_init('md5');
- hash_update($ctx,'the quick brown fox');
- hash_update($ctx,'jumped over the lazy dog.');
- echo hash_final($ctx);
-
- $str="the quick brown fox jumped over the lazy dog.";
- $fp=tmpfile();
- fwrite($fp,$str);
- rewind($fp);
- $ctx=hash_init('md5');
- hash_update_stream($ctx,$fp);
- echo hash_final($ctx);
-
-
- $str="the quick brown fox jumped over the lazy dog.";
- echo hash_hmac('ripemd160',$str,'secret');
-
-
- $file="example.txt";
- $str=" the quick brown fox jumped over the lazy dog.";
- file_put_contents($file,$str);
- echo hash_hmac_file('md5',$file,'secret');
-
- $ctx=hash_init('sha1');
- hash_update($ctx,'the quick brown fox jumped over the lazy dog.');
- echo hash_final($ctx);
|