CRYPT-SHA512
This commit is contained in:
parent
e9d658e4bd
commit
e0865608a2
|
@ -2025,6 +2025,7 @@ function password_types() {
|
|||
|
||||
return array(
|
||||
''=>'clear',
|
||||
'crypt-sha512' => 'crypt-sha512',
|
||||
'crypt'=>'crypt',
|
||||
'md5'=>'md5',
|
||||
'sha'=>'sha',
|
||||
|
@ -2076,6 +2077,12 @@ function pla_password_hash($password_clear,$enc_type) {
|
|||
$new_value = sprintf('{SMD5}%s',base64_encode(mhash(MHASH_MD5,$password_clear.$salt).$salt));
|
||||
break;
|
||||
|
||||
case 'crypt-sha512':
|
||||
mt_srand((double)microtime()*1000000);
|
||||
$salt = bin2hex(mhash_keygen_s2k(MHASH_SHA1,$password_clear,substr(pack('h*',md5(mt_rand())),0,8),16));
|
||||
$new_value = "{CRYPT}" . crypt($password_clear, '$6$' . $salt);
|
||||
break;
|
||||
|
||||
case 'clear':
|
||||
default:
|
||||
$new_value = $password_clear;
|
||||
|
@ -2207,6 +2214,17 @@ function password_check($cryptedpassword,$plainpassword,$attribute='userpassword
|
|||
return false;
|
||||
}
|
||||
|
||||
# Check if it's SHA512
|
||||
elseif (strstr($cryptedpassword,'$6$')) {
|
||||
|
||||
list($dummy,$type,$salt,$hash) = explode('$',$cryptedpassword);
|
||||
|
||||
if (crypt($plainpassword,'$6$'.$salt) == $cryptedpassword)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
# Check if it's extended des crypt
|
||||
elseif (strstr($cryptedpassword,'_')) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue