public static SecureRandom getInstance (String algorithm) throws NoSuchAlgorithmException

Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.

This method traverses the list of registered security Providers, starting with the most preferred Provider. A new SecureRandom object encapsulating the SecureRandomSpi implementation from the first Provider that supports the specified algorithm is returned.

Note that the list of registered providers may be retrieved via the Security.getProviders() method.

The returned SecureRandom object has not been seeded. To seed the returned object, call the setSeed method. If setSeed is not called, the first call to nextBytes will force the SecureRandom object to seed itself. This self-seeding will not occur if setSeed was previously called.

Parameters:
algorithm    the name of the RNG algorithm. See the SecureRandom section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard RNG algorithm names.

Returns:  the new SecureRandom object.

Exceptions:
NoSuchAlgorithmException    if no Provider supports a SecureRandomSpi implementation for the specified algorithm.

See also:
Provider

Since:  1.2