Skip to content

Commit 254ada2

Browse files
committed
Update crypto.random
1 parent 9daccff commit 254ada2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

docs/Runtime Environment/Crypto.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,18 @@ print(crypto.ripemd160("Pluto")) --> c2072a85f4a691803b8942709036072086fd9550
258258
## Cryptographic PRNGs
259259
### `crypto.random`
260260
This is a cryptographically secure PRNG, assuming the platform's implementation of the underlying primitive is secure.
261+
#### Parameters
262+
This function takes 0-2 integer parameters that define the output range:
263+
- If no arguments are given, an inclusive range from `math.mininteger` to `math.maxinteger` is used.
264+
- If 1 argument (`n`) is given, an inclusive range from 1 to `n` is used.
265+
- If 2 arguments (`l`, `u`) are given, an inclusive range from `l` to `u` is used.
261266
#### Returns
262-
A random lua integer, in the range from `math.mininteger` to `math.maxinteger`.
267+
A random lua integer, in the given range.
263268
```pluto
264269
local crypto = require("crypto")
265-
print(crypto.random())
270+
print(crypto.random()) -- Prints an integer from math.mininteger to math.maxinteger.
271+
print(crypto.random(6)) -- Prints an integer from 1 to 6, like a dice roll.
272+
print(crypto.random(10, 20)) -- Prints an integer from 10 to 20.
266273
```
267274

268275
---

0 commit comments

Comments
 (0)