php提供的使用者密碼加密函式

2022-07-28 05:15:15 字數 408 閱讀 3080

在實際專案中,對使用者的密碼加密基本上採用的  md5加鹽的方式,

php5.5後提供了乙個加密函式,不需要手動加鹽,不需要去維護鹽值,

$str = "123456";

$pwd = password_hash($str,password_default);

echo

$pwd

;if( password_verify("123456",$pwd

) )

password_default- 使用 bcrypt 演算法 (php 5.5.0 預設)。 注意,該常量會隨著 php 加入更新更高強度的演算法而改變。

所以,使用此常量生成結果的長度將在未來有變化。 因此,資料庫裡儲存結果的列可超過60個字元(最好是255個字元)。

php加密函式

計應134 實驗班 周露玲 php中能對資料進行加密的函式只要有crypt md5 和shal 還有加密擴充套件庫mcrypt和mash。crypt 函式 crypt 函式可以完成單向加密功能,語法如下 string crypt string str string salt crypt 接受兩個引數...

PHP加密函式

1.使用crypt 函式進行加密 string crypt string str string salt 其中,str引數是需要加密的字串,salt引數為加密時使用的干擾串。如果省略掉第二個引數,則會隨機生成乙個干擾串。2.使用md5 函式進行加密 string md5 string str boo...

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...