Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
langjava
byte[] randomBytes = new byte[128];
SecureRandom random = new SecureRandom();
random.nextBytes(randomBytes);

It is also good practice to specify Specifying the exact random number generator RNG algorithm and provider for better portabilitycan improve portability, perhaps when complying with a design or regulation that mandates a particular algorithm. However, if no arguments are provided, the constructor will provide a default secure RNG.

Applicability

Insufficiently secure random numbers enable attackers to gain specific information about the context in which they are used.

...