Soenneker.Extensions.RandomNumberGenerators
4.0.25
Prefix Reserved
dotnet add package Soenneker.Extensions.RandomNumberGenerators --version 4.0.25
NuGet\Install-Package Soenneker.Extensions.RandomNumberGenerators -Version 4.0.25
<PackageReference Include="Soenneker.Extensions.RandomNumberGenerators" Version="4.0.25" />
<PackageVersion Include="Soenneker.Extensions.RandomNumberGenerators" Version="4.0.25" />
<PackageReference Include="Soenneker.Extensions.RandomNumberGenerators" />
paket add Soenneker.Extensions.RandomNumberGenerators --version 4.0.25
#r "nuget: Soenneker.Extensions.RandomNumberGenerators, 4.0.25"
#:package Soenneker.Extensions.RandomNumberGenerators@4.0.25
#addin nuget:?package=Soenneker.Extensions.RandomNumberGenerators&version=4.0.25
#tool nuget:?package=Soenneker.Extensions.RandomNumberGenerators&version=4.0.25
Soenneker.Extensions.RandomNumberGenerators
Uniform 64-bit signed, unsigned, and bounded sampling from a cryptographic RandomNumberGenerator.
Installation
dotnet add package Soenneker.Extensions.RandomNumberGenerators
Sample a bounded signed integer
using Soenneker.Extensions.RandomNumberGenerators;
using RandomNumberGenerator rng = RandomNumberGenerator.Create();
long index = rng.GetInt64(exclusiveMax: 1_000); // 0 through 999
long signed = rng.GetInt64(-500, 500); // -500 through 499
Both bounded overloads use rejection sampling rather than % alone, so every value in the requested interval has the same probability.
GetInt64(exclusiveMax)returns a value in[0, exclusiveMax)and requires a positive maximum.GetInt64(min, max)returns a value in[min, max)and supports intervals spanning the negative and positive halves of the complete signed range. It requiresmin < max.
Invalid bounds throw ArgumentOutOfRangeException. The generator must be non-null.
Sample the full 64-bit domain
long anySigned = rng.GetInt64();
ulong anyUnsigned = rng.GetUInt64();
The parameterless methods sample uniformly across all bit patterns of Int64 or UInt64, respectively. The signed result can be negative. GetUInt64() fills eight bytes and interprets them in little-endian order; byte order does not affect uniformity.
Randomness quality and disposal behavior come from the supplied RandomNumberGenerator. These methods are suitable for cryptographic sampling when the supplied generator is suitable, but converting a random value to text does not by itself provide enough entropy for every token format—choose the range/bit count according to the security requirement.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.25 | 94 | 9/24/2026 |
| 4.0.24 | 109 | 9/15/2026 |
| 4.0.23 | 115 | 9/12/2026 |
| 4.0.22 | 126 | 8/30/2026 |
| 4.0.21 | 113 | 8/29/2026 |
| 4.0.20 | 129 | 7/27/2026 |
| 4.0.19 | 131 | 7/16/2026 |
| 4.0.18 | 142 | 6/19/2026 |
| 4.0.17 | 124 | 6/5/2026 |
| 4.0.16 | 132 | 4/22/2026 |
| 4.0.15 | 128 | 3/13/2026 |
| 4.0.14 | 127 | 3/12/2026 |
| 4.0.13 | 126 | 3/12/2026 |
| 4.0.11 | 133 | 3/12/2026 |
| 4.0.10 | 137 | 3/10/2026 |
| 4.0.9 | 122 | 3/9/2026 |
| 4.0.8 | 127 | 3/9/2026 |
| 4.0.7 | 123 | 3/9/2026 |
| 4.0.6 | 121 | 3/4/2026 |
| 4.0.5 | 132 | 1/18/2026 |
Enable Native AOT compatibility analysis