mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
see https://github.com/postfixadmin/postfixadmin/issues/422 - not all variants of MySQL have RANDOM_BYTES()
This commit is contained in:
1 parent
dd7d94912b
commit
189bd583a0
1 file changed
+2
-1
+2
-1
@@ -943,7 +943,8 @@ function _pacrypt_mysql_encrypt($pw, $pw_db = '') {
|
||||
} else {
|
||||
// see https://security.stackexchange.com/questions/150687/is-it-safe-to-use-the-encrypt-function-in-mysql-to-hash-passwords
|
||||
// if no existing password, use a random SHA512 salt.
|
||||
$res= db_query_one("SELECT ENCRYPT(:pw, CONCAT('$6$', SHA2(RANDOM_BYTES(64), '256'))) as result", ['pw' => $pw]);
|
||||
$salt = _php_crypt_generate_crypt_salt();
|
||||
$res= db_query_one("SELECT ENCRYPT(:pw, CONCAT('$6$', '$salt')) as result", ['pw' => $pw]);
|
||||
}
|
||||
|
||||
return $res['result'];
|
||||
|
||||
Reference in new issue
Block a user