Creating a SecureRandom Object

A new secure random-number generator object can be created as follows:

SecureRandom randomNumbers = new SecureRandom();

It can then be used to generate random values—we discuss only random int values here. For more information on the SecureRandom class, see docs.oracle.com/javase/7/docs/api/java/security/SecureRandom.html.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.