$newpasshash = crypt("비밀번호", '$6$rounds=10000$salts$');
$6 : SHA512 //SHA256은 $5
rounds=10000 : 해싱루프 숫자 : 1000 ~ 999999999 까지
salts : 임의의 문자열
결과 : $6$rounds=10000$salts$oS9pt.WPNWUrsuH64IR8jC0i0vbHTRHJRC5tCD.fw.lgHtFxB6Y6FuqhNt6WQschEyBLK1sTN8qUURZDV672e.
비교 :
if(validate_pw("비밀번호", "$6$rounds=10000$salts$oS9pt.WPNWUrsuH64IR8jC0i0vbHTRHJRC5tCD.fw.lgHtFxB6Y6FuqhNt6WQschEyBLK1sTN8qUURZDV672e.")){
echo "암호일치";
}else{
echo "불일치";
}
function validate_pw($password, $hash){
/* Regenerating the with an available hash as the options parameter should
* produce the same hash if the same password is passed.
*/
return crypt($password, $hash)==$hash;
}
'PHP' 카테고리의 다른 글
PHP7 session_regenerate_id() 대체 (0) | 2019.01.08 |
---|---|
IIS PHP 헤더설정 (0) | 2019.01.08 |
CentOS7 에서 php7.2 yum 설치 (0) | 2018.06.07 |
CentOS7 PHP7 oci8.so 설치 (0) | 2017.11.07 |
php-mcrypt 설치가 안될 때 (0) | 2017.11.05 |