Update PasswordHash.php

This commit is contained in:
laf
2014-02-23 22:05:22 +00:00
parent 18f9b89639
commit 519e4aba84

View File

@@ -48,11 +48,18 @@ class PasswordHash {
function get_random_bytes($count) function get_random_bytes($count)
{ {
$output = ''; $output = '';
$output = openssl_random_pseudo_bytes($count,$strong);
if(empty($count))
{
if (is_readable('/dev/urandom') && if (is_readable('/dev/urandom') &&
($fh = @fopen('/dev/urandom', 'rb'))) { ($fh = @fopen('/dev/urandom', 'rb')))
{
$output = fread($fh, $count); $output = fread($fh, $count);
fclose($fh); fclose($fh);
} }
}
if (strlen($output) < $count) { if (strlen($output) < $count) {
$output = ''; $output = '';