2

As i seen, True RNG (TRNG) in a software-only program is impossible. Modern CPUs not providing TRNG to your software. For example, Intel CPUs starting from Ivy Bridge 3rd generation supports RDRND which uses thermal noise from the processor's circuits to generate random numbers. AMD modern CPUs also support RDRND too, starting from AMD FX "Bulldozer" CPUs (2011), also have TRNG support like Intel's feature.

For example, this is a code uses Pseudo-Random Numbers Generation (PRNG):

import random
random_numbers = [random.randint(0, 100) for _ in range(10)]

print("10 Random Numbers:")
print(random_numbers)

Can i get True RNG-based random numbers in python using system CPU's features? Without using sites provide True RNG numbers like this site.

0

1 Answer 1

2

The secrets module, added in Python 3.6, is the best way to get cryptographic-quality random numbers in Python in an easy and portable way. The docs for it state:

The secrets module provides access to the most secure source of randomness that your operating system provides.

Most operating systems will use CPU randomizer sources, in addition to others, in their cryptographically secure random number generator, and these will in turn be used by the Python secrets module.

Whether these are true random numbers or not is perhaps more of a philosophical issue than a practical one.

Sign up to request clarification or add additional context in comments.

5 Comments

It's right, the secrets module is generates numbers better than random module, but it's not a true random number generation?
Define "true random number generator." It's surprisingly difficult. However, if you are running on a CPU with RDRAND or equivalent, it's very likely that secrets is incorporating that randomness into its output, e.g. if you are running on Linux, Windows, or MacOS.
Affect my research, secret module uses OS's feature, and Windows or macOS won't use CPU's RDRND feature if supported. Linux is very unlikely to support, unless a special kernel installed.
My research indicates just the opposite, that Linux, Windows, and MacOS will use CPU randomizers if the CPUs have them.
From where? If you give me, thanks you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.