function _openid_get_bytes

2 calls to _openid_get_bytes()
OpenIDTest::testOpenidGetBytes in drupal/core/modules/openid/lib/Drupal/openid/Tests/OpenIDTest.php
Test _openid_get_bytes().
_openid_dh_rand in drupal/core/modules/openid/openid.inc

File

drupal/core/modules/openid/openid.inc, line 547
OpenID utility functions.

Code

function _openid_get_bytes($num_bytes) {
  $f =& drupal_static(__FUNCTION__);
  $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;
}