php常用hash加密函式

2022-10-06 11:30:10 字數 1720 閱讀 8727

複製** **如下:

$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('www.cppcns.commd5', 'example.txt');

$str="the quick brown fox jumped over the lazy dog.";      //定義字串

echo hash('ripemd160',$str);           //生成雜湊值

$ctx=hash_init('md5');          //初始化乙個hash值

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');    www.cppcns.com;      //初始化乙個hash值

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');      //生成包含金鑰的hash值

/*建立乙個檔案並將字串寫入其中*/

$file="exam程式設計客棧ple.txt";          //定義檔名

$str=" the quick brown fox jumped over the lazy dog.";   //定義字串

file_put_contents($file,$str);        //向檔案中寫入字串

echo hash_hmac_file('md5',$file,'secret');      //生成乙個包含金鑰的hash值

$ctx=hash_init('sha1');       &nbwww.cppcns.comsp;  //定義字串

hash_update($ctx,'the quick brown fox jumped over the lazy dog.');  //向雜湊值中灌注資料

echo hash_final($ctx);  //輸出結果

本文標題: php常用hash加密函式

本文位址:

PHP常用加密函式

define str 墨劍 echo md5 加密後的結果為 md5 str md5 加密 echo crypt加密後的結果為 crypt str,str crypt加密 base64encode base64 encode str base64 encode 加密 echo base64 enco...

php 常用加密函式

md5 md5 預設情況下以 32 字元十六進製制數字形式返回雜湊值,它接受兩個引數,第乙個為要加密的字串,第二個為raw output的布林值,預設為false,如果設定為true,md5 則會返回原始的 16 位二進位制格式報文摘要 md5 為單向加密,沒有逆向解密演算法,但是還是可以對一些常見...

Hash密碼加密函式

function tlogin form.hash password password string string it must incloud unit dcpcrypt2 and dcpsha1 var i integer str1,str2 string hash tdcp sha1 dig...