mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-22 05:29:34 +01:00
Merge pull request #259 from RalphORama/master
Use random_bytes if PHP version >= 7.1.0
This commit is contained in:
commit
74283b131d
@ -69,8 +69,14 @@ function test_password($password, $salt, $test) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generate_salt() {
|
function generate_salt() {
|
||||||
|
// mcrypt_create_iv() was deprecated in PHP 7.1.0, only use it if we're below that version number.
|
||||||
|
if (PHP_VERSION_ID < 70100) {
|
||||||
// 128 bits of entropy
|
// 128 bits of entropy
|
||||||
return strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
|
return strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, use random_bytes()
|
||||||
|
return strtr(base64_encode(random_bytes(16)), '+', '.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function login($username, $password) {
|
function login($username, $password) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user