N/crypto/random Module: Secure Random Data Generation
The N/crypto/random module provides methods for generating secure random bytes, integers, and UUIDs in SuiteScript applications.
The N/crypto/random module enables developers to generate secure random data needed for various applications within NetSuite. This module is available for both client and server scripts, making it versatile for different scripting needs.
What Methods Are Available in the N/crypto/random Module?
The N/crypto/random module includes the following primary methods:
random.generateBytes(options)
- Return Type:
Uint8Array - Description: Generates a cryptographically strong pseudorandom set of bytes.
- Parameters:
Parameter Type Required / Optional Description options.sizenumber Required The number of bytes to generate; between 1 and 512.
Code Sample:
// Generate 5 random bytes of datavar bytes = random.generateBytes({size: 5});random.generateInt(options)
- Return Type:
number - Description: Generates a cryptographically strong pseudorandom number.
- Parameters:
Parameter Type Required / Optional Description options.maxnumber Required End of random range (exclusive). options.minnumber Optional Start of random range; default is 0.
Code Sample:
// Generate a random number between 0 and 100 (excluded)var number = random.generateInt({max: 100});// Generate a random number between 10 and 100 (excluded)var anotherNumber = random.generateInt({min: 10, max: 100});random.generateUUID()
- Return Type:
string - Description: Generates a v4 Universally Unique Identifier (UUID) using a secure random number generator.
Who This Affects
This module is particularly useful for:
- Developers creating custom scripts that require secure random data.
- Administrators managing security protocols that depend on unique identifiers or random data generation.
Key Takeaways
- The N/crypto/random module provides essential functions for secure random data generation.
- Available for both client and server scripts, enhancing flexibility.
- Critical for applications requiring unique identifiers or secure pseudorandom numbers.
Source: This article is based on Oracle's official NetSuite documentation.
Frequently Asked Questions (4)
Do I need to enable a feature flag to use the N/crypto/random module?
How many bytes can I generate using the random.generateBytes method?
Can random.generateInt generate both positive and negative numbers?
Is the random.generateUUID method suitable for client scripts?
Was this article helpful?
More in General
- Payment Date Prediction Feature in NetSuite
Payment Date Prediction in NetSuite utilizes machine learning to enhance financial planning by predicting invoice payment dates.
- NetSuite Ship Central Enhancements for Packing & Shipping
NetSuite Ship Central features enhance packing and shipping operations for improved efficiency and accuracy.
- New Role Setup for NetSuite AI Connector Service in 2026.1
The 2026.1 release adds a new role requirement for the NetSuite AI Connector Service, streamlining custom tool development.
- Generative AI Features in NetSuite 2026.1
Discover new generative AI features in NetSuite 2026.1, enhancing reporting, search, predictions, and development productivity.
Advertising
Reach General Professionals
Put your product in front of NetSuite experts who work with General every day.
Sponsor This Category