Open kralos opened 3 years ago
Any strings yielded by the built in PseudoRandomStringGenerators only use [0-9][a-f] however the alphabet has a lot more to offer. Especially if you count uppercase...
PseudoRandomStringGenerator
[0-9][a-f]
Facebook\PseudoRandomString\PseudoRandomStringGeneratorTrait
public function binToHex($binaryData, $length) { return \substr(\bin2hex($binaryData), 0, $length); }
e.g.
class RandomIntBase62CSPRSG implements \Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface { /** * Indexing a string is faster than using \chr() */ private const CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; public static function getPseudoRandomString( int $length ): string { $string = ''; for ($i = 0; $i < $length; $i++) { $string .= static::CHARS[\random_int(0, 61)]; } return $string; } }
I don't think they care anymore....
Any strings yielded by the built in
PseudoRandomStringGenerator
s only use[0-9][a-f]
however the alphabet has a lot more to offer. Especially if you count uppercase...Facebook\PseudoRandomString\PseudoRandomStringGeneratorTrait
e.g.