SecureRandomGen function
Syntax
SecureRandomGen([num][, bytes])
Description
Use the SecureRandomGen function to generate one or more cryptographically secure pseudo-random number generator (CSPRNG) values. For example, a CSPRNG value can be used as a salt to then generate a hashed (or “salted”) string, such as a hashed password.
Note:
Because SecureRandomGen is based on the Java security SecureRandom function, it is more efficient to call it once to return an array of required salt values than it is to call it for each salt value required.
Parameters
| Parameter | Description |
|---|---|
|
num |
Specifies the number of random numbers to generate. If this value is not specified, one random number is generated. |
|
bytes |
Specifies the size of each random number in bytes. If this value is less than 1 or not specified, the default is 16 bytes (128 bits). |
Returns
An array of string.
Example
In this example, SecureRandomGen generates an array with one 16-byte value:
Local array of string &operpwsdsalt;
&operpwsdsalt = SecureRandomGen();
In this example, SecureRandomGen generates an array with four 16-byte values:
Local array of string &operpwsdsalt;
&operpwsdsalt = SecureRandomGen(4);
In this example, SecureRandomGen generates an array with four 32-byte values.
Local array of string &operpwsdsalt;
&operpwsdsalt = SecureRandomGen(4, 32);
Related Topics