Merge pull request #102 from KiTTYsh/master

Use random_bytes() to generate IV where available (PHP 7.x)
This commit is contained in:
Appleman1234 2017-05-04 10:20:11 +09:00 committed by GitHub
commit 7c8f857c3b

View File

@ -70,7 +70,11 @@ function test_password($password, $salt, $test) {
function generate_salt() { function generate_salt() {
// 128 bits of entropy // 128 bits of entropy
if (function_exists('random_bytes')) {
return strtr(base64_encode(random_bytes(16)), '+', '.');
} else {
return strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.'); return strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
}
} }
function login($username, $password) { function login($username, $password) {