Dotnet library for reading random numbers from a CPU's digital random number generator (DRNG).
This library contains methods for invoking the RDRAND and RDSEED instructions on Intel and AMD CPUs.
See https://www.intel.com/content/www/us/en/developer/articles/guide/intel-digital-random-number-generator-drng-software-implementation-guide.html for more details
Install the ReadRandom package from NuGet (https://www.nuget.org/packages/ReadRandom)
using ReadRandom;
// Read a random seed value from the CPU
uint seed = Cpu.ReadRandomSeed();
// Read a random value from the CPU
uint random = Cpu.ReadRandom();
- Requires a Windows x64 process. Values are 32-bit unsigned integers.
- Checks CPU support before executing either instruction. Use
Cpu.IsRdRandSupportedandCpu.IsRdSeedSupportedto check availability; unsupported calls throwPlatformNotSupportedException. - Reads retry until the CPU reports success, so they have no fixed timeout.
