コード例 #1
0
ファイル: util.php プロジェクト: bashrc/gnusocial-debian
/**
 * returns $bytes bytes of raw random data
 */
function common_random_rawstr($bytes)
{
    $rawstr = @file_exists('/dev/urandom') ? common_urandom($bytes) : common_mtrand($bytes);
    return $rawstr;
}
コード例 #2
0
ファイル: util.php プロジェクト: himmelex/NTW
function common_good_rand($bytes)
{
    // XXX: use random.org...?
    if (@file_exists('/dev/urandom')) {
        return common_urandom($bytes);
    } else {
        // FIXME: this is probably not good enough
        return common_mtrand($bytes);
    }
}
コード例 #3
0
ファイル: util.php プロジェクト: phpsource/gnu-social
/**
 * returns $bytes bytes of random data as a hexadecimal string
 */
function common_random_hexstr($bytes)
{
    $str = @file_exists('/dev/urandom') ? common_urandom($bytes) : common_mtrand($bytes);
    $hexstr = '';
    for ($i = 0; $i < $bytes; $i++) {
        $hexstr .= sprintf("%02x", ord($str[$i]));
    }
    return $hexstr;
}