allow to select chars for randomString()

This commit is contained in:
maxpozdeev 2022-09-08 11:18:31 +03:00
parent d9ba34d5b4
commit 85140018dd

View file

@ -177,9 +177,8 @@ function isValidSignature(string $signature, string $id, string $key, string $sa
}
function randomString(int $len = 16) : string
function randomString(int $len = 16, string $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') : string
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$a = [];
$max = strlen($chars) - 1;
for ($i = 0; $i < $len; $i++) {