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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Extensions.RandomNumberGenerators" Version="4.0.25" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.RandomNumberGenerators" Version="4.0.25" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.RandomNumberGenerators" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Extensions.RandomNumberGenerators --version 4.0.25
                    
#r "nuget: Soenneker.Extensions.RandomNumberGenerators, 4.0.25"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Extensions.RandomNumberGenerators@4.0.25
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Extensions.RandomNumberGenerators&version=4.0.25
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.RandomNumberGenerators&version=4.0.25
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 requires min < 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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
Loading failed

Enable Native AOT compatibility analysis