Merge pull request #4 from torrentpier/simplified-make_rand_str-function

Simplified make_rand_str function
This commit is contained in:
Roman Kelesidis 2023-03-11 16:49:33 +07:00 committed by GitHub
commit ac33bb064b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,12 +301,7 @@ function str_compact ($str)
function make_rand_str ($len = 10)
{
$str = '';
while (strlen($str) < $len)
{
$str .= str_shuffle(preg_replace('#[^0-9a-zA-Z]#', '', crypt(uniqid(mt_rand(), true))));
}
return substr($str, 0, $len);
return substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', (int)$len)), 0, $len);
}
// bencode: based on OpenTracker