Class SecureRandom
- java.lang.Object
-
- java.util.Random
-
- java.security.SecureRandom
-
- All Implemented Interfaces:
Serializable
public class SecureRandom extends Random
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SecureRandom()Constructs a secure random number generator (RNG) implementing the default random number algorithm.SecureRandom(byte[] seed)Constructs a secure random number generator (RNG) implementing the default random number algorithm.
-
-
-
Constructor Detail
-
SecureRandom
public SecureRandom()
Constructs a secure random number generator (RNG) implementing the default random number algorithm.This constructor 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 a SecureRandom (RNG) algorithm is returned. If none of the Providers support a RNG algorithm, then an implementation-specific default is returned.
Note that the list of registered providers may be retrieved via the
Security.getProviders()method.See the SecureRandom section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard RNG algorithm names.
The returned SecureRandom object has not been seeded. To seed the returned object, call the
setSeedmethod. IfsetSeedis not called, the first call tonextByteswill force the SecureRandom object to seed itself. This self-seeding will not occur ifsetSeedwas previously called.
-
SecureRandom
public SecureRandom(byte[] seed)
Constructs a secure random number generator (RNG) implementing the default random number algorithm. The SecureRandom instance is seeded with the specified seed bytes.This constructor 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 a SecureRandom (RNG) algorithm is returned. If none of the Providers support a RNG algorithm, then an implementation-specific default is returned.
Note that the list of registered providers may be retrieved via the
Security.getProviders()method.See the SecureRandom section in the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard RNG algorithm names.
- Parameters:
seed- the seed.
-
-