Encoding & cryptographyReference
crypt.random
Generate a raw binary string of random bytes.
Details#
Generate a raw binary string of random bytes. Exactly size raw bytes; 0 returns an empty string. Invalid sizes and generator failure raise errors.
Signature#
crypt.random(size: number): stringParameters#
| Parameter | Type | Description |
|---|---|---|
size | number | Integer byte count from 0 to 1048576. |
Returns#
Exactly size raw bytes; 0 returns an empty string. Invalid sizes and generator failure raise errors.
Examples#
Local example
local bytes = crypt.random(16)
print(#bytes) -- 16