SecureRandomNumberGenerator

Default implementation of the {@link RandomNumberGenerator RandomNumberGenerator} interface, backed by a {@link SecureRandom SecureRandom} instance. <p/> This class is a little easier to use than using the JDK's {@code SecureRandom} class directly. It also allows for JavaBeans-style of customization, convenient for Shiro's INI configuration or other IoC configuration mechanism.

@since 1.1

Constructors

this
this()

Creates a new instance with a default backing {@link SecureRandom SecureRandom} and a {@link #getDefaultNextBytesSize() defaultNextBytesSize} of {@code 16}, which equals 128 bits, a size commonly used in cryptographic algorithms.

Members

Functions

getDefaultNextBytesSize
int getDefaultNextBytesSize()

Returns the size of the generated byte array for calls to {@link #nextBytes() nextBytes()}. Defaults to {@code 16}, which equals 128 bits, a size commonly used in cryptographic algorithms.

getSecureRandom
SecureRandom getSecureRandom()

Returns the {@link SecureRandom SecureRandom} backing this instance.

nextBytes
ByteSource nextBytes()
Undocumented in source. Be warned that the author may not have intended to support it.
nextBytes
ByteSource nextBytes(int numBytes)
Undocumented in source. Be warned that the author may not have intended to support it.
setDefaultNextBytesSize
void setDefaultNextBytesSize(int defaultNextBytesSize)

Sets the size of the generated byte array for calls to {@link #nextBytes() nextBytes()}. Defaults to {@code 16}, which equals 128 bits, a size commonly used in cryptographic algorithms.

setSecureRandom
void setSecureRandom(SecureRandom random)

Sets the {@link SecureRandom SecureRandom} to back this instance.

setSeed
void setSeed(byte[] bytes)

Seeds the backing {@link SecureRandom SecureRandom} instance with additional seed data.

Variables

DEFAULT_NEXT_BYTES_SIZE
enum int DEFAULT_NEXT_BYTES_SIZE;
Undocumented in source.

Inherited Members

From RandomNumberGenerator

nextBytes
ByteSource nextBytes()

Generates a byte array of fixed length filled with random data, often useful for generating salts, initialization vectors or other seed data. The length is specified as a configuration value on the underlying implementation. <p/> If you'd like per-invocation control the number of bytes generated, use the {@link #nextBytes(int) nextBytes(int)} method instead.

nextBytes
ByteSource nextBytes(int numBytes)

Generates a byte array of the specified length filled with random data.

Meta