$hash_list=hash_algos(); //返回注冊(cè)的hash規(guī)則列表
print_r($hash_list); //顯示結(jié)果
創(chuàng)建文件以計(jì)算哈希值:file_put_contents('example.txt', 'the quick brown fox jumped over the lazy dog.');
輸出哈希值信息:
轉(zhuǎn)載請(qǐng)注明來(lái)源:php中常用hash加密函數(shù)
- echo hash_file('md5', 'example.txt');
- $str="the quick brown fox jumped over the lazy dog."; //定義字符串
- echo hash('ripemd160',$str); //生成哈希值
- $ctx=hash_init('md5'); //初始化一個(gè)hash值
- hash_update($ctx,'the quick brown fox'); //向哈希值灌注數(shù)據(jù)
- hash_update($ctx,'jumped over the lazy dog.'); //向哈希值灌注數(shù)據(jù)
- echo hash_final($ctx); //輸出最后的結(jié)果
- $str="the quick brown fox jumped over the lazy dog."; //定義字符串
- $fp=tmpfile(); //創(chuàng)建一個(gè)臨時(shí)文件
- fwrite($fp,$str); //將字符串寫入到臨時(shí)文件
- rewind($fp); //倒回文件指針的位置
- $ctx=hash_init('md5'); //初始化一個(gè)hash值
- hash_update_stream($ctx,$fp); //向數(shù)據(jù)流中灌注數(shù)據(jù)
- echo hash_final($ctx); //輸出結(jié)果
- $str="the quick brown fox jumped over the lazy dog."; //定義字符串
- echo hash_hmac('ripemd160',$str,'secret'); //生成包含密鑰的hash值
- /*創(chuàng)建一個(gè)文件并將字符串寫入其中*/
- $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'); //生成一個(gè)包含密鑰的hash值
- $ctx=hash_init('sha1'); //定義字符串
- hash_update($ctx,'the quick brown fox jumped over the lazy dog.'); //向哈希值中灌注數(shù)據(jù)
- echo hash_final($ctx); //輸出結(jié)果
- //開源代碼phpfensi.com
哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無(wú)需額外費(fèi)用,即可穩(wěn)步提升排名至首頁(yè)。歡迎體驗(yàn)最佳的哈爾濱網(wǎng)站建設(shè)。
