Constructors
- ✓public SecureRandom()
- ✗public SecureRandom(byte[] arg0)Comparing jdk-20-ga and jdk-21+35
SecureRandom
public SecureRandom(byte[] seed) Constructs a secure random number generator (RNG) implementing the default random number algorithm. TheSecureRandominstance is seeded with the specified seed bytes.This constructor traverses the list of registered security Providers, starting with the most preferred Provider. A new
SecureRandomobject encapsulating theSecureRandomSpiimplementation from the first provider that supports aSecureRandom(RNG) algorithm is returned. If none of the providers support an 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
SecureRandomsection in the Java Security Standard Algorithm Names Specification for information about standard RNG algorithm names.- Parameters:
seed- the seed.- Throws:
NullPointerException- ifseedisnull
- ✓protected SecureRandom(java.security.SecureRandomSpi arg0, java.security.Provider arg1)
Methods
- ✓public byte[] generateSeed(int arg0)
- ✓public java.lang.String getAlgorithm()
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0) throws java.security.NoSuchAlgorithmException
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0, java.lang.String arg1) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0, java.security.Provider arg1) throws java.security.NoSuchAlgorithmException
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0, java.security.SecureRandomParameters arg1) throws java.security.NoSuchAlgorithmException
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0, java.security.SecureRandomParameters arg1, java.lang.String arg2) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
- ✓public static java.security.SecureRandom getInstance(java.lang.String arg0, java.security.SecureRandomParameters arg1, java.security.Provider arg2) throws java.security.NoSuchAlgorithmException
- ✓public static java.security.SecureRandom getInstanceStrong() throws java.security.NoSuchAlgorithmException
- ✓public java.security.SecureRandomParameters getParameters()
- ✓public final java.security.Provider getProvider()
- ✓public static byte[] getSeed(int arg0)
- ✓protected final int next(int arg0)
- ✗public void nextBytes(byte[] arg0)Comparing jdk-20-ga and jdk-21+35
nextBytes
public void nextBytes(byte[] bytes) Generates a user-specified number of random bytes.- Specified by:
nextBytesin interfaceRandomGenerator- Overrides:
nextBytesin classRandom- Parameters:
bytes- the array to be filled in with random bytes.- Throws:
NullPointerException- ifbytesisnull
- ✗public void nextBytes(byte[] arg0, java.security.SecureRandomParameters arg1)Comparing jdk-20-ga and jdk-21+35
nextBytes
Generates a user-specified number of random bytes with additional parameters.- Parameters:
bytes- the array to be filled in with random bytesparams- additional parameters- Throws:
NullPointerException- ifbytesisMoved to a computer code block.null
Moved to a computer code block. UnsupportedOperationException- if the underlying provider implementation has not overridden this methodIllegalArgumentException- ifparamsisnull, illegal or unsupported by thisSecureRandom- Since:
- 9
- ✓public void reseed()
- ✓public void reseed(java.security.SecureRandomParameters arg0)
- ✓public void setSeed(long arg0)
- ✗public void setSeed(byte[] arg0)Comparing jdk-20-ga and jdk-21+35
setSeed
public void setSeed(byte[] seed) Reseeds this random object with the given seed. The seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.A PRNG
SecureRandomwill not seed itself automatically ifsetSeedis called before anynextBytesorreseedcalls. The caller should make sure that theseedargument contains enough entropy for the security of thisSecureRandom.- Parameters:
seed- the seed.- Throws:
NullPointerException- ifseedisnull- See Also:
- ✓public java.lang.String toString()
Serialized Form
✓serialVersionUID
✓4940670005562187Serialized Fields
- ✓java.lang.String algorithm
- ✓long counter
- ✓java.security.MessageDigest digest
- ✓java.security.Provider provider
- ✓byte[] randomBytes
- ✓int randomBytesUsed
- ✓java.security.SecureRandomSpi secureRandomSpi
- ✓byte[] state
- ✓boolean threadSafe
Summary
| Elements | Comments | Descriptions | Total | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed | ||
| nextBytes(byte[]) | 4 | 4 | ||||||||
| nextBytes(byte[],SecureRandomParameters) | 2 | 2 | ||||||||
| setSeed(byte[]) | 3 | 3 | ||||||||
| <init>(byte[]) | 4 | 4 | ||||||||
| Total | 11 | 2 | 13 | |||||||