Laravel框架中
(1) 輔助方法:'加鹽' 加密解密 :
public function myTest(){
//用戶密碼
$str = "password";
//加鹽加密,每次加密之後生成的字符串不同。
$encryptStr = encrypt($str);
//解密
$decryptStr = decrypt($encryptStr);
dd($decryptStr==$str);
}
(2)門面:Hash加密和驗證
public function myTest(){
//用戶密碼
$str = "password";
//使用門面Hash中make()方法來將密碼進行加密。
$hashStr = Hash::make($str);
//使用check()方法,進行驗證,對比當前密碼和數據庫加密之後的密碼是否相同。
$booleanValue = Hash::check($str,$hashStr);
dd($booleanValue);
}