SecureRandom.NetCore
1.0.0
dotnet add package SecureRandom.NetCore --version 1.0.0
NuGet\Install-Package SecureRandom.NetCore -Version 1.0.0
<PackageReference Include="SecureRandom.NetCore" Version="1.0.0" />
paket add SecureRandom.NetCore --version 1.0.0
#r "nuget: SecureRandom.NetCore, 1.0.0"
// Install SecureRandom.NetCore as a Cake Addin #addin nuget:?package=SecureRandom.NetCore&version=1.0.0 // Install SecureRandom.NetCore as a Cake Tool #tool nuget:?package=SecureRandom.NetCore&version=1.0.0
SecureRandom.NetCore
Implementation of a cryptographic pseudorandom number generator (CPRNG) using Blake2b. Optimized for PinnedMemory.
Install
From a command prompt
dotnet add package SecureRandom.NetCore
Install-Package SecureRandom.NetCore
You can also search for the package via your nuget ui / website:
https://www.nuget.org/packages/SecureRandom.NetCore/
Examples
You can find more examples in the github examples project.
var cprng = new SecureRandom();
var randomBytes = cprng.NextBytes(16); // create by length
var nextRandomBytes = new byte[32];
cprng.NextBytes(nextRandomBytes); // popualte by size
Constructor
WARNING: Never set seed to false unless you know what your doing. See example in github for more details.
SecureRandom(int rounds = 10, bool seed = true)
Methods
Get the hash output length used when seeding.
int GetSeedLength()
Will add bytes to existing seed material, this will be hashed with blake2b.
void SetSeed(byte[] seed)
Will add number to existing seed material, this will be hashed with blake2b.
void SetSeed(long seed)
Will return a random number between 0, and int.MaxValue.
int Next()
Will return a random number between 0, and maxValue.
int Next(int maxValue)
Will return a random number between minValue, and maxValue.
int Next(int minValue, int maxValue)
Will return random bytes at length.
byte[] NextBytes(int length)
Will populate random bytes by size.
void NextBytes(byte[] bytes)
Will populate random bytes with offset at length.
void NextBytes(byte[] bytes, int offset, int length)
Will return a random double between double.MinValue, and double.MaxValue.
double NextDouble()
Will return a random int between int.MinValue, and int.MaxValue.
int NextInt()
Will return a random long between long.MinValue, and long.MaxValue.
int NextLong()
Will free state, and all seed material.
void Dispose()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Blake2b.NetCore (>= 1.0.1)
- PinnedMemory (>= 1.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on SecureRandom.NetCore:
Package | Downloads |
---|---|
Curve25519.NetCore
An elliptic curve offering 128 bits of security and designed for use with the elliptic curve Diffie–Hellman (ECDH) key agreement scheme. It is one of the fastest ECC curves and is not covered by any known patents. |
|
BigInteger.NetCore
Implementation of a arbitrary-precision arithmetic method using SecureRandom. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 7,600 | 7/27/2020 |