New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ticket/15723] Rewrite gen_rand_string() and gen_rand_string_friendly() #5292
Conversation
unique_id returned 16 characters before, i think it should return 32 better. |
@@ -88,21 +97,25 @@ function gen_rand_string($num_chars = 8) | |||
*/ | |||
function gen_rand_string_friendly($num_chars = 8) | |||
{ | |||
$rand_str = bin2hex(random_bytes($num_chars + 1)); | |||
$range = array_merge(range('A', 'N'), range('P', 'Z'), range(1, 9)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add [a-z] too I think
@@ -73,8 +73,17 @@ function set_var(&$result, $var, $type, $multibyte = false) | |||
*/ | |||
function gen_rand_string($num_chars = 8) | |||
{ | |||
// [a, z] + [0, 9] = 36 | |||
return substr(strtoupper(base_convert(bin2hex(random_bytes($num_chars + 1)), 16, 36)), 0, $num_chars); | |||
$range = array_merge(range('A', 'Z'), range(0, 9)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add [a-z] too I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, is the same characters, in the old version of the function, all characters were converted to uppercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
[ticket/15723] Rewrite gen_rand_string() and gen_rand_string_friendly()
PHPBB3-15723
Checklist:
Tracker ticket (set the ticket ID to your ticket ID):
https://tracker.phpbb.com/browse/PHPBB3-15723