GlideSecureRandomUtil - Scoped

The scoped GlideSecureRandomUtil API provides methods for generating integers, long values, and strings.

There is no constructor for this class. Methods are accessed through the static object GlideSecureRandomUtil. The GlideSecureRandomUtil class is available in both global and scoped applications.

Scoped GlideSecureRandomUtil - getSecureRandomInt()

Generates a pseudo-random integer.

Table 1. Parameters
Name Type Description
None
Table 2. Returns
Type Description
Number The pseudo-randomly generated integer.
gs.info(GlideSecureRandomUtil.getSecureRandomInt());
Output:
1976146969

Scoped GlideSecureRandomUtil - getSecureRandomIntBound(Number bound)

Generates a pseudo-random integer between 0 (inclusive) and the bound (exclusive) value that you pass into the method.

Table 3. Parameters
Name Type Description
bound Number The bound value.
Table 4. Returns
Type Description
Number The pseudo-randomly generated integer.
gs.info(GlideSecureRandomUtil.getSecureRandomIntBound(100));
Output:
55

Scoped GlideSecureRandomUtil - getSecureRandomLong()

Generates pseudo-random long value.

Table 5. Parameters
Name Type Description
None
Table 6. Returns
Type Description
Number The pseudo-randomly generated 64-bit integer.
gs.info(GlideSecureRandomUtil.getSecureRandomLong());
Output:
792836514424092500

Scoped GlideSecureRandomUtil - getSecureRandomString(Number length)

Generates a random alpha-numeric String with the specified length.

Table 7. Parameters
Name Type Description
length Number The length of the string in number of characters.
Table 8. Returns
Type Description
String The randomly generated string.
gs.info(GlideSecureRandomUtil.getSecureRandomString(12));
Output:
1XzVI0sLfVlT