Files
drmaterac.pl/modules/pshowsso/deps/paragonie/random-lib/lib/RandomLib/Source/UniqID.php
Jacek Pyziak 778ee26fe4 Add Symfony Deprecation Contracts package
- Created CHANGELOG.md to maintain version history.
- Added README.md with usage instructions for the trigger_deprecation() function.
- Initialized composer.json for the Symfony Deprecation Contracts library, specifying dependencies and autoloading.
2025-12-15 08:43:18 +01:00

78 lines
1.9 KiB
PHP

<?php
/*
* The RandomLib library for securely generating random numbers and strings in PHP
*
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
* @copyright 2011 The Authors
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version Build @@version@@
*/
/**
* The UniqID Random Number Source
*
* This uses the internal `uniqid()` function to generate low strength random
* numbers.
*
* PHP version 5.3
*
* @category PHPCryptLib
* @package Random
* @subpackage Source
*
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
* @copyright 2011 The Authors
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*
* @version Build @@version@@
*/
namespace PShowSsoScoped\RandomLib\Source;
use PShowSsoScoped\SecurityLib\Strength;
use PShowSsoScoped\SecurityLib\Util;
/**
* The UniqID Random Number Source
*
* This uses the internal `uniqid()` function to generate low strength random
* numbers.
*
* @category PHPCryptLib
* @package Random
* @subpackage Source
*
* @author Anthony Ferrara <ircmaxell@ircmaxell.com>
* @codeCoverageIgnore
*/
class UniqID extends \PShowSsoScoped\RandomLib\AbstractSource
{
/**
* Return an instance of Strength indicating the strength of the source
*
* @return \PShowSsoScoped\SecurityLib\Strength An instance of one of the strength classes
*/
public static function getStrength()
{
return new Strength(Strength::LOW);
}
/**
* Generate a random string of the specified size
*
* @param int $size The size of the requested random string
*
* @return string A string of the requested size
*/
public function generate($size)
{
$result = '';
while (Util::safeStrlen($result) < $size) {
$result = uniqid($result, true);
}
return Util::safeSubstr($result, 0, $size);
}
}