Share via


SecureRandom Constructors

Definition

Overloads

SecureRandom()

Constructs a secure random number generator (RNG) implementing the default random number algorithm.

SecureRandom(Byte[])

Constructs a secure random number generator (RNG) implementing the default random number algorithm.

SecureRandom(SecureRandomSpi, Provider)

Creates a SecureRandom object.

SecureRandom(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

SecureRandom()

Constructs a secure random number generator (RNG) implementing the default random number algorithm.

[Android.Runtime.Register(".ctor", "()V", "")]
public SecureRandom ();
Attributes

Remarks

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() 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 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.

Java documentation for java.security.SecureRandom.SecureRandom().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SecureRandom(Byte[])

Constructs a secure random number generator (RNG) implementing the default random number algorithm.

[Android.Runtime.Register(".ctor", "([B)V", "")]
public SecureRandom (byte[]? seed);
[<Android.Runtime.Register(".ctor", "([B)V", "")>]
new Java.Security.SecureRandom : byte[] -> Java.Security.SecureRandom

Parameters

seed
Byte[]

the seed.

Attributes

Remarks

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() Security.getProviders() method.

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

Java documentation for java.security.SecureRandom.SecureRandom(byte[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SecureRandom(SecureRandomSpi, Provider)

Creates a SecureRandom object.

[Android.Runtime.Register(".ctor", "(Ljava/security/SecureRandomSpi;Ljava/security/Provider;)V", "")]
protected SecureRandom (Java.Security.SecureRandomSpi? secureRandomSpi, Java.Security.Provider? provider);
[<Android.Runtime.Register(".ctor", "(Ljava/security/SecureRandomSpi;Ljava/security/Provider;)V", "")>]
new Java.Security.SecureRandom : Java.Security.SecureRandomSpi * Java.Security.Provider -> Java.Security.SecureRandom

Parameters

secureRandomSpi
SecureRandomSpi

the SecureRandom implementation.

provider
Provider

the provider.

Attributes

Remarks

Creates a SecureRandom object.

Java documentation for java.security.SecureRandom.SecureRandom(java.security.SecureRandomSpi, java.security.Provider).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

SecureRandom(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected SecureRandom (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Java.Security.SecureRandom : nativeint * Android.Runtime.JniHandleOwnership -> Java.Security.SecureRandom

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to