Improve 2FA

This commit is contained in:
Frederic Guillot
2016-01-05 20:31:15 -05:00
parent 811254ba93
commit e62779e267
9 changed files with 191 additions and 80 deletions

View File

@@ -21,15 +21,7 @@ class Token extends Base
*/
public static function getToken()
{
if (function_exists('random_bytes')) {
return bin2hex(random_bytes(30));
} elseif (function_exists('openssl_random_pseudo_bytes')) {
return bin2hex(openssl_random_pseudo_bytes(30));
} elseif (ini_get('open_basedir') === '' && strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
return hash('sha256', file_get_contents('/dev/urandom', false, null, 0, 30));
}
return hash('sha256', uniqid(mt_rand(), true));
return bin2hex(random_bytes(30));
}
/**