Class RandomNumberGenerator
- Namespace
- CryptoHives.Foundation.Security.Cryptography.Rng
- Assembly
- CryptoHives.Foundation.Security.Cryptography.dll
Polyfill for RandomNumberGenerator.
public class RandomNumberGenerator : IDisposable
- Inheritance
-
RandomNumberGenerator
- Implements
- Inherited Members
Methods
Create()
When overridden in a derived class, creates an instance of the default implementation of a cryptographic random number generator that can be used to generate random data.
public static RandomNumberGenerator Create()
Returns
- RandomNumberGenerator
A new instance of a cryptographic random number generator.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
When overridden in a derived class, releases the unmanaged resources used by the RandomNumberGenerator and optionally releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
Fill(byte[])
Fills the specified span with cryptographically strong random bytes.
public static void Fill(byte[] data)
Parameters
databyte[]
Fill(Span<byte>)
Fills the specified span with cryptographically strong random bytes.
public static void Fill(Span<byte> data)
Parameters
GetBytes(byte[])
When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of values.
public void GetBytes(byte[] data)
Parameters
databyte[]The array to fill with cryptographically strong random bytes.
GetBytes(byte[], int, int)
Fills the specified byte array with a cryptographically strong random sequence of values.
public void GetBytes(byte[] data, int offset, int count)
Parameters
databyte[]The array to fill with cryptographically strong random bytes.
offsetintThe index of the array to start the fill operation.
countintThe number of bytes to fill.
Exceptions
- ArgumentNullException
datais null.- ArgumentOutOfRangeException
offsetorcountis less than 0- ArgumentException
offsetpluscountexceeds the length ofdata.
GetBytes(Span<byte>)
Fills a span with cryptographically strong random bytes.
public void GetBytes(Span<byte> data)