RandomLib icon indicating copy to clipboard operation
RandomLib copied to clipboard

Is the new Random\Randomizer::getBytesFromString a replacement for this lib?

Open garak opened this issue 1 year ago • 0 comments

Hello, I've been using this library for some years, and recently I noticed that PHP just added a getBytesFromString function. So I was wondering if I could replace the usage of this library with that new native implementation.

Example of old code:

<?php

$factory = new RandomLib\Factory;
$generator = $factory->getMediumStrengthGenerator();
$randomString = $generator->generateString(8, 'abcdefghijklmnopqrstuvwxyz0123456789');

example of possible replacement:

<?php

$randomizer = new \Random\Randomizer();
$randomString = $randomizer->getBytesFromString('abcdefghijklmnopqrstuvwxyz0123456789', 8);

If so, what would be the matching strength of the generator?

garak avatar Dec 24 '23 08:12 garak