_openid_get_bytes

6 openid.inc _openid_get_bytes($num_bytes)
7 openid.inc _openid_get_bytes($num_bytes)
8 openid.inc _openid_get_bytes($num_bytes)

1 call to _openid_get_bytes()

File

modules/openid/openid.inc, line 372
OpenID utility functions.

Code

function _openid_get_bytes($num_bytes) {
  static $f = null;
  $bytes = '';
  if (!isset($f)) {
    $f = @fopen(OPENID_RAND_SOURCE, "r");
  }
  if (!$f) {
    // pseudorandom used
    $bytes = '';
    for ($i = 0; $i < $num_bytes; $i += 4) {
      $bytes .= pack('L', mt_rand());
    }
    $bytes = substr($bytes, 0, $num_bytes);
  }
  else {
    $bytes = fread($f, $num_bytes);
  }
  return $bytes;
}
Login or register to post comments