Is there a reason why Str::random doesn't use bin2hex? #41523
Unanswered
arsel-5lvxa7b1
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I was going through the implementation of
Str::random
and found that it usesbase64_encode
withstr_replace
that removes unneeded symbols, running this in loop to achieve the length needed. Isn't it shorter to just usebin2hex(random_bytes($size))
? Some reason we can't?Method in question:
https://github.com/laravel/framework/blob/9.x/src/Illuminate/Support/Str.php#L632-L645
Beta Was this translation helpful? Give feedback.
All reactions