Get unpredictable, secure random numbers for your C# programs

Generating True Random Numbers in C#

How to use cryptographically secure random number generators in your C# code

Valdarix Games
3 min readDec 21, 2022

--

Photo by Alex Chambers on Unsplash

Generating a random number is not necessarily difficult, but generating a truly random number can be challenging.

A random number is a number that is chosen in a way that is impossible to predict. In other words, the number appears to be chosen randomly and is not influenced by any external factors.

In order to generate a random number, a computer program must use a random number generator (RNG) algorithm. This algorithm uses a seed value, which is a starting value that is used to generate a sequence of random numbers. The seed value is typically generated using information from the computer’s internal state, such as the current time or the processor’s cycle count.

The problem with most RNG algorithms is that they are not truly random. Instead, they are pseudo-random, which means that they use a deterministic algorithm to generate a sequence of numbers that appears to be random. However, because the algorithm is deterministic, the sequence of numbers it generates will be the same every time the program is run. This means that the numbers are not truly…

--

--

Valdarix Games

Turning my passion for video games and software development experience into a focus on video game development.