Bug #19653 » 9852.diff
t3lib/class.t3lib_div.php (working copy) | ||
---|---|---|
return strtr((string)$str, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
||
}
|
||
/**
|
||
* Returns a string of highly randomized bytes (over the full 8-bit range).
|
||
*
|
||
* @copyright Drupal CMS
|
||
* @license GNU General Public License version 2
|
||
* @param integer Number of characters (bytes) to return
|
||
* @return string Random Bytes
|
||
*/
|
||
public static function generateRandomBytes($count) {
|
||
// We initialize with the somewhat random PHP process ID on the
|
||
// first call.
|
||
if (empty($random_state)) {
|
||
$random_state = getmypid();
|
||
}
|
||
$output = '';
|
||
// /dev/urandom is available on many *nix systems and is considered
|
||
// the best commonly available pseudo-random source.
|
||
if ($fh = @fopen('/dev/urandom', 'rb')) {
|
||
$output = fread($fh, $count);
|
||
fclose($fh);
|
||
}
|
||
// fallback if /dev/urandom is not available
|
||
while (!isset($output{$count - 1})) {
|
||
$random_state = md5(microtime() . mt_rand() . $random_state);
|
||
$output .= md5(mt_rand() . $random_state, true);
|
||
}
|
||
return substr($output, 0, $count);
|
||
}
|
||