3 ms·
There are situations where the Pyhton random module can provide easy API for cryptographically unpredictable events. E.g. you can pick random words for passphr
by maqp 6y ago
There are situations where the Pyhton random module can provide easy API for cryptographically unpredictable events.
E.g. you can pick random words for passphrase from wordlist with random.SystemRandom().choice(word_list). SystemRandom is a CSPRNG. It's of course incredibly dangerous that you can accidentally use MT by forgetting to put in the SystemRandom() part. random.choice(word_list) works as well and doesn't fail tests.
It would be really important to make all RNGs cryptographically secure unless explicitly stated that the RNG must be very fast at the cost of predictability, and the naming should reflect that, e.g. insecure_scientific_random.randint() for Monte Carlo simulations etc.