Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6958d6

Browse filesBrowse files
committed
[#6104] Minor formatting fixes
1 parent 932530f commit d6958d6
Copy full SHA for d6958d6

File tree

Expand file treeCollapse file tree

1 file changed

+13
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-14
lines changed

‎components/security/secure_tools.rst

Copy file name to clipboardExpand all lines: components/security/secure_tools.rst
+13-14Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Securely Generating Random Values
2-
=================================
1+
Securely Comparing Strings and Generating Random Values
2+
=======================================================
33

44
The Symfony Security component comes with a collection of nice utilities
55
related to security. These utilities are used by Symfony, but you should
@@ -25,8 +25,7 @@ Generating a Secure Random String
2525
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2626

2727
Whenever you need to generate a secure random string, you are highly
28-
encouraged to use the
29-
:phpfunction:`random_bytes` function::
28+
encouraged to use the :phpfunction:`random_bytes` function::
3029

3130
$random = random_bytes(10);
3231

@@ -35,26 +34,26 @@ the number bytes passed as an argument (10 in the above example).
3534

3635
.. tip::
3736

38-
The ``random_bytes()`` function returns a binary string which may contain the
39-
``\0`` character. This can cause trouble in several common scenarios, such
40-
as storing this value in a database or including it as part of the URL. The
41-
solution is to encode or hash the value returned by ``random_bytes()`` (to do that, you
42-
can use a simple ``base64_encode()`` PHP function).
37+
The ``random_bytes()`` function returns a binary string which may contain
38+
the ``\0`` character. This can cause trouble in several common scenarios,
39+
such as storing this value in a database or including it as part of the
40+
URL. The solution is to encode or hash the value returned by
41+
``random_bytes()`` (to do that, you can use a simple ``base64_encode()``
42+
PHP function).
4343

4444
Generating a Secure Random Number
4545
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4646

4747
If you need to generate a cryptographically secure random integer, you should
48-
use the
49-
:phpfunction:`random_int` function::
48+
use the :phpfunction:`random_int` function::
5049

5150
$random = random_int(1, 10);
5251

5352
.. note::
5453

55-
PHP 7 and up provide the ``random_bytes()`` and ``random_int()`` functions natively,
56-
for older versions of PHP a polyfill is provided by the `Symfony Polyfill Component`_
57-
and the `paragonie/random_compat package`_.
54+
PHP 7 and up provide the ``random_bytes()`` and ``random_int()`` functions
55+
natively, for older versions of PHP a polyfill is provided by the
56+
`Symfony Polyfill Component`_ and the `paragonie/random_compat package`_.
5857

5958
.. _`Timing attack`: https://en.wikipedia.org/wiki/Timing_attack
6059
.. _`Symfony Polyfill Component`: https://github.com/symfony/polyfill

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.