function zen_pwd_rand($min = 0, $max = 10)
{
    static $seed;
    if (!isset($seed)) {
        $seed = zen_get_entropy();
    }
    $random = hash('sha1', zen_get_entropy() . $seed);
    $random .= hash('sha1', zen_get_entropy() . $random);
    $random = hash('sha1', $random);
    $random = substr($random, 0, 8);
    $value = abs(hexdec($random));
    $value = $min + ($max - $min + 1) * ($value / (4294967295.0 + 1));
    $value = abs(intval($value));
    return $value;
}
예제 #2
0
function zen_pwd_rand($min = 0, $max = 10)
{
    static $seed;
    if (!isset($seed)) {
        $seed = zen_get_entropy(microtime());
    }
    $random = zen_get_entropy($seed);
    $random .= zen_get_entropy($random);
    $random = sha1($random);
    $random = substr($random, 0, 8);
    $value = abs(hexdec($random));
    $value = $min + ($max - $min + 1) * ($value / (4294967295 + 1));
    $value = abs(intval($value));
    return $value;
}