public static SecureRandom getInstance (String algorithm, Provider provider) throws NoSuchAlgorithmException

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

A new SecureRandom object encapsulating the SecureRandomSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.

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.
provider    the provider.

Returns:  the new SecureRandom object.

Exceptions:
NoSuchAlgorithmException    if a SecureRandomSpi implementation for the specified algorithm is not available from the specified Provider object.
IllegalArgumentException    if the specified provider is null.

See also:
Provider

Since:  1.4