Contain classes that generate random data/value using a cryptographic random number generator.
- SaidOut.Security.ISecureRandom Generate random data/value using a cryptographic random number generator.
- SaidOut.Security.SecureRandom Generate random data/value using a new cryptographic random number generator each time it generates a random data/value.
- SaidOut.Security.SecureRandomContext Generate random data/value using the same cryptographic random number generator each time it generates a random data/value in the same random context.
Name | Description |
---|---|
GenerateRandomData |
Create a byte array of size with random data. |
GenerateRandomValue |
Generate a random value in the range [min , max ]. |
Interface is implemented by SecureRandom
and SecureRandomContext
.
Name | Description |
---|---|
GenerateRandomData |
Create a byte array of size with random data. |
GenerateRandomValue |
Generate a random value in the range [min , max ]. |
Generate random data/value using a new cryptographic random number generator each time it generates a random data/value.
If you need to generate multiple random data/values at the same time use SecureRandomContext
.
Example
var nonce = SecureRandom.GenerateRandomData(15);
var radomVal = SecureRandom.GenerateRandomValue(10, 50); // radomVal set to a value between 10 and 50.
Name | Description |
---|---|
GenerateRandomData |
Create a byte array of size with random data. |
GenerateRandomValue |
Generate a random value in the range [min , max ]. |
Generate random data/value using the same cryptographic random number generator each time it generates a random data/value in the same random context.
Use this class if you need to generate multiple random data/values at the same time use.
Example
using (var secRndCtx = new SecureRandomContext())
{
var keyA = secRndCtx.GenerateRandomData(15);
var keyB = secRndCtx.GenerateRandomData(15);
var nonce = secRndCtx.GenerateRandomData(15);
var randomVal = secRndCtx.GenerateRandomValue(10, 50);
}