Project

General

Profile

Bug #19653 » 9852_v3.diff

Administrator Admin, 2008-11-29 05:27

View differences:

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) {
$output = '';
// /dev/urandom is available on many *nix systems and is considered
// the best commonly available pseudo-random source.
if (TYPO3_OS != 'WIN' && ($fh = @fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
// fallback if /dev/urandom is not available
if (!isset($output{$count - 1})) {
$randomState = getmypid();
while (!isset($output{$count - 1})) {
$randomState = sha1(microtime() . mt_rand() . $randomState);
$output .= sha1(mt_rand() . $randomState, true);
}
$output = substr($output, strlen($output) - $count, $count);
}
return $output;
}
(2-2/2)