ChaCha Constructor

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0

Overload List

ChaCha() Initializes a new instance of the ChaCha class using OS entropy.
ChaCha(RandomOptions) Initializes a new instance of the ChaCha class with the specified options.
ChaCha(ReadOnlySpan<Byte>) Initializes a new instance of the ChaCha class from saved state.
ChaCha(Int64, ChaChaVariant) Constructs a new ChaCha random number generator with the specified seed and variant.
ChaCha(Int64, SeedProfile) Initializes a new instance of the ChaCha class with the specified seed.
ChaCha(ReadOnlySpan<UInt32>, SeedProfile) Initializes a new instance of the ChaCha class with the specified seed array.
ChaCha(ReadOnlySpan<UInt64>, ChaChaVariant) Constructs a new ChaCha random number generator with the specified seed and variant.
ChaCha(Int64, StreamAddress, ChaChaVariant) Constructs a new ChaCha random number generator with the specified seed, stream ID, and variant.
ChaCha(Int64, StreamAddress, SeedProfile) Initializes a new instance of the ChaCha class with the specified seed.
ChaCha(ReadOnlySpan<UInt32>, StreamAddress, SeedProfile) Initializes a new instance of the ChaCha class with the specified seed array.

ChaCha

Initializes a new instance of the ChaCha class using OS entropy.
C#
public ChaCha()

ChaCha(RandomOptions)

Initializes a new instance of the ChaCha class with the specified options.
C#
public ChaCha(
	RandomOptions options
)

Parameters

options  RandomOptions
The initialization options containing seed, stream ID, and seed profile.

ChaCha(ReadOnlySpan<Byte>)

Initializes a new instance of the ChaCha class from saved state.
C#
public ChaCha(
	ReadOnlySpan<byte> state
)

Parameters

state  ReadOnlySpan<Byte>
The saved state to restore.

Exceptions

ArgumentExceptionThe length of state is less than the required state size.

ChaCha(Int64, ChaChaVariant)

Constructs a new ChaCha random number generator with the specified seed and variant.
C#
public ChaCha(
	long seed,
	ChaChaVariant variant
)

Parameters

seed  Int64
The initial seed of the generator.
variant  ChaChaVariant
The ChaCha variant.

Remarks

This constructor uses the SplitMix64 seeding algorithm and Generic stream mode.

Variant mapping:

Example

C#
var rng = new ChaCha20(54321, ChaChaVariant.ChaCha8);

Exceptions

ArgumentOutOfRangeExceptionThrown when variant is not a valid ChaChaVariant value.

ChaCha(Int64, SeedProfile)

Initializes a new instance of the ChaCha class with the specified seed.
C#
public ChaCha(
	long seed,
	SeedProfile seedProfile = SeedProfile.Default
)

Parameters

seed  Int64
A number used to calculate a starting value for the pseudo-random number sequence.
seedProfile  SeedProfile  (Optional)
The seed profile to use for initialization.

ChaCha(ReadOnlySpan<UInt32>, SeedProfile)

Initializes a new instance of the ChaCha class with the specified seed array.
C#
public ChaCha(
	ReadOnlySpan<uint> seedMaterial,
	SeedProfile seedProfile = SeedProfile.Default
)

Parameters

seedMaterial  ReadOnlySpan<UInt32>
An array of numbers used to calculate a starting value for the pseudo-random number sequence.
seedProfile  SeedProfile  (Optional)
The seed profile to use for initialization.

Exceptions

ArgumentNullExceptionseedMaterial is null.

ChaCha(ReadOnlySpan<UInt64>, ChaChaVariant)

Constructs a new ChaCha random number generator with the specified seed and variant.
C#
public ChaCha(
	ReadOnlySpan<ulong> seedArray,
	ChaChaVariant variant
)

Parameters

seedArray  ReadOnlySpan<UInt64>
The seed array values.
variant  ChaChaVariant
The ChaCha variant.

Remarks

This constructor uses the SplitMix64 seeding algorithm and Generic stream mode.

Variant mapping:

Exceptions

ArgumentOutOfRangeExceptionThrown when variant is not a valid ChaChaVariant value.

ChaCha(Int64, StreamAddress, ChaChaVariant)

Constructs a new ChaCha random number generator with the specified seed, stream ID, and variant.
C#
public ChaCha(
	long seed,
	StreamAddress streamAddress,
	ChaChaVariant variant
)

Parameters

seed  Int64
The initial seed of the generator.
streamAddress  StreamAddress
Optional stream identifier for stream selection.
variant  ChaChaVariant
The ChaCha variant.

Remarks

This constructor uses the SplitMix64 seeding algorithm.

Variant mapping:

Exceptions

ArgumentOutOfRangeExceptionThrown when variant is not a valid ChaChaVariant value.

ChaCha(Int64, StreamAddress, SeedProfile)

Initializes a new instance of the ChaCha class with the specified seed.
C#
public ChaCha(
	long seed,
	StreamAddress streamAddress,
	SeedProfile seedProfile = SeedProfile.Default
)

Parameters

seed  Int64
A number used to calculate a starting value for the pseudo-random number sequence.
streamAddress  StreamAddress
Optional stream identifier for stream selection.
seedProfile  SeedProfile  (Optional)
The seed profile to use for initialization.

ChaCha(ReadOnlySpan<UInt32>, StreamAddress, SeedProfile)

Initializes a new instance of the ChaCha class with the specified seed array.
C#
public ChaCha(
	ReadOnlySpan<uint> seedMaterial,
	StreamAddress streamAddress,
	SeedProfile seedProfile = SeedProfile.Default
)

Parameters

seedMaterial  ReadOnlySpan<UInt32>
An array of numbers used to calculate a starting value for the pseudo-random number sequence.
streamAddress  StreamAddress
Optional stream address for stream selection.
seedProfile  SeedProfile  (Optional)
The seed profile to use for initialization.

Exceptions

ArgumentNullExceptionseedMaterial is null.

See Also