Skip to content

Commit 2996f0b

Browse files
committed
minor #4709 Add caution note for random function usage (xelan)
This PR was merged into the 3.x branch. Discussion ---------- Add caution note for random function usage See https://www.php.net/manual/en/function.array-rand.php and https://www.php.net/manual/en/function.mt-rand.php. Users should know that the Twig function is a convenience feature, but unusable e.g. for serious gaming/gambling apps due to the potential predictability and limited value range. Commits ------- 02c5a4b Add caution note for random function usage
2 parents 94a3635 + 02c5a4b commit 2996f0b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/functions/random.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ parameter type:
1010
* a random integer between the integer parameter (when negative) and 0 (inclusive).
1111
* a random integer between the first integer and the second integer parameter (inclusive).
1212

13+
.. caution::
14+
15+
The ``random`` function does not produce cryptographically secure random numbers.
16+
Do not use them for purposes that require returned values to be unguessable.
17+
1318
.. code-block:: twig
1419
1520
{{ random(['apple', 'orange', 'citrus']) }} {# example output: orange #}

0 commit comments

Comments
 (0)