Skip to content

Commit b46bce1

Browse files
committed
minor #9838 Don't recommend base64 encoding of random_bytes result (javiereguiluz)
This PR was merged into the 2.8 branch. Discussion ---------- Don't recommend base64 encoding of random_bytes result This fixes #9348. base64 is not safe for URLs, so let's recommend hashing the values. Commits ------- 18cd815 Don't recommend base64 encoding of random_bytes result
2 parents 4f119ad + 18cd815 commit b46bce1

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

components/security/secure_tools.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ the number bytes passed as an argument (10 in the above example).
4141
The ``random_bytes()`` function returns a binary string which may contain
4242
the ``\0`` character. This can cause trouble in several common scenarios,
4343
such as storing this value in a database or including it as part of the
44-
URL. The solution is to encode or hash the value returned by
45-
``random_bytes()`` (to do that, you can use a simple ``base64_encode()``
46-
PHP function).
44+
URL. The solution is to hash the value returned by ``random_bytes()`` with
45+
a hashing function such as :phpfunction:`md5` or :phpfunction:`sha1`.
4746

4847
Generating a Secure Random Number
4948
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)