dw.crypto
Class SecureRandom

The SecureRandom class provides a cryptographically strong random number generator (RNG).
See the Internet Engineering Task Force (IETF) RFC 1750: Randomness Recommendations for
Security for more information.
Typical callers of SecureRandom invoke the following methods to retrieve random bytes:
Bytes bytes... SecureRandom random = new SecureRandom(); Bytes nextBytes = random.nextBytes(bytes);or more convenient to get a Bytes with the demanded length
int length = 32; SecureRandom random = new SecureRandom(); Bytes nextBytes = random.nextBytes(length);dw.crypto.SecureRandom is intentionally an adapter for generating cryptographic hard random numbers.
Constructor Summary
SecureRandom()
Instantiates a new secure random.
Method Summary
generateSeed(numBytes
:
Number)
:
Bytes
Returns the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself.
nextInt()
:
Number
Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
nextInt(upperBound
:
Number)
:
Number
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
nextNumber()
:
Number
Returns the next pseudorandom, uniformly distributed Number value between 0.0 (inclusive) and 1.0 (exclusive) from this random number generator's sequence.
Methods inherited from class
Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Salesforce Commerce Cloud Courses
Salesforce B2C Commerce Developer - Certification Tests
Why risk failing the SFCC exam? Get 180 real questions, killer content, and everything you need to crush the Salesforce B2C Commerce Developer certification.
Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβpassing the certification exam isn't easy. That's where we come in.
Becoming a Salesforce B2C Commerce Developer is your ticket to higher salaries, better job opportunities, and the credibility to stand out from the competition. But let's be honestβpassing the certification exam isn't easy. That's where we come in.
Salesforce Javascript Developer I - Certification Tests
Not just another prep courseβthis is your shortcut to passing. Master JavaScript for Salesforce and go from 'hoping to pass' to knowing you will. Ready to start?
This isn't just another prep courseβit's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
This isn't just another prep courseβit's your shortcut to mastering the skills and confidence you need to pass. With multiple practice tests covering every section and a final exam simulation designed to mirror the real thing, you'll feel like you've already aced it before test day.
Salesforce B2C Commerce Architect - Certification Tests
Think the Developer exam was hard? Welcome to the next level.
The Salesforce B2C Commerce Architect certification is a whole different gameβcomplex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
The Salesforce B2C Commerce Architect certification is a whole different gameβcomplex solutions, elevated difficulty, and skills that set you apart in the eCommerce industry. That's why we're including 11 downloadable PDF guides, packed with best practices and strategies to help you prepare for the exam and build confidence in every topic.
Method Detail
generateSeed
Returns the given number of seed bytes, computed using the seed
generation algorithm that this class uses to seed itself. This
call may be used to seed other random number generators.
Parameters:
numBytes
-
the number of seed bytes to generate.
Returns:
the seed bytes.
nextBytes
Generates a user-specified number of random bytes.
If a call to setSeed
had not occurred previously,
the first call to this method forces this SecureRandom object
to seed itself. This self-seeding will not occur if
setSeed
was previously called.
Parameters:
numBits
-
the demanded number of bits
Returns:
a randomly filled Bytes
nextInt
nextInt()
:
Number
Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence. The general
contract of nextInt is that one int value is pseudorandomly generated and returned. All 232
possible int values are produced with (approximately) equal probability.
Returns:
the next pseudorandom, uniformly distributed int value from this random number generator's sequence
nextInt
Returns a pseudorandom, uniformly distributed int value
between 0 (inclusive) and the specified value (exclusive), drawn from
this random number generator's sequence.
Parameters:
upperBound
-
the bound on the random number to be returned. Must be positive.
Returns:
the next pseudorandom, uniformly distributed int value between 0 (inclusive) and upperBound (exclusive) from this random number generator's sequence
Throws:
IllegalArgumentException
-
if n is not positive
nextNumber
nextNumber()
:
Number
Returns the next pseudorandom, uniformly distributed
Number value between 0.0 (inclusive) and 1.0 (exclusive) from this random number generator's sequence.
Returns:
the next pseudorandom, uniformly distributed Number value between 0.0 and 1.0 from this random number generator's sequence
setSeed
setSeed(seed
:
Bytes)
:
void
Reseeds this random object. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.
Parameters:
seed
-
the seed.