【PHP】 hash加密

以前對密碼進行加密是在JS文件裏作的,可是不行,改到PHP文件裏進行加密比較安全,因而乎……php

【原JS加密代碼】算法

var password = sha256_digest(pwd);

 

後來在網上調查方法,見附,就把php代碼改爲了下面這個樣子,就好用了安全

【PHP】函數

$p = $_POST["password"];
$password = hash('sha256',$p);

 

附【參考】加密

<?php
$string='password';
echo hash('md5',$string);//新的hash函數,第一個參數指定算法名稱
?>
hash支持的加密算法有:
   [0] => md4
   [1] => md5
   [2] => sha1
   [3] => sha256
   [4] => sha384
   [5] => sha512
   [6] => ripemd128
   [7] => ripemd160
   [8] => whirlpool
   [9] => tiger128,3
   [10] => tiger160,3
   [11] => tiger192,3
   [12] => tiger128,4
   [13] => tiger160,4
   [14] => tiger192,4
   [15] => snefru
   [16] => gost
   [17] => adler32
   [18] => crc32
   [19] => crc32b
   [20] => haval128,3
   [21] => haval160,3
   [22] => haval192,3
   [23] => haval224,3
   [24] => haval256,3
   [25] => haval128,4
   [26] => haval160,4
   [27] => haval192,4
   [28] => haval224,4
   [29] => haval256,4
   [30] => haval128,5
   [31] => haval160,5
   [32] => haval192,5
   [33] => haval224,5
   [34] => haval256,5
相關文章
相關標籤/搜索