mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/15693] Fix get_rand_string()
PHPBB3-15693
This commit is contained in:
parent
8b7ae7c796
commit
f75c400db4
1 changed files with 2 additions and 2 deletions
|
@ -71,7 +71,7 @@ function set_var(&$result, $var, $type, $multibyte = false)
|
||||||
function gen_rand_string($num_chars = 8)
|
function gen_rand_string($num_chars = 8)
|
||||||
{
|
{
|
||||||
// [a, z] + [0, 9] = 36
|
// [a, z] + [0, 9] = 36
|
||||||
return substr(strtoupper(base_convert(unique_id(), 16, 36)), 0, $num_chars);
|
return substr(strtoupper(base_convert(bin2hex(random_bytes($num_chars)), 16, 36)), 0, $num_chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +82,7 @@ function gen_rand_string($num_chars = 8)
|
||||||
*/
|
*/
|
||||||
function gen_rand_string_friendly($num_chars = 8)
|
function gen_rand_string_friendly($num_chars = 8)
|
||||||
{
|
{
|
||||||
$rand_str = unique_id();
|
$rand_str = bin2hex(random_bytes($num_chars));
|
||||||
|
|
||||||
// Remove Z and Y from the base_convert(), replace 0 with Z and O with Y
|
// Remove Z and Y from the base_convert(), replace 0 with Z and O with Y
|
||||||
// [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34
|
// [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34
|
||||||
|
|
Loading…
Add table
Reference in a new issue