|
|
Subscribe / Log in / New account

Python and crypto-strength random numbers by default

Python and crypto-strength random numbers by default

Posted Sep 17, 2015 12:12 UTC (Thu) by ianmcc (subscriber, #88379)
Parent article: Python and crypto-strength random numbers by default

I think its a bad idea to try to make the default RNG cryptographically secure. People who don't know what they're doing will misuse it anyway, and if they're too clueless to read the documentation and learn how to do cryptography properly (which probably involves stepping away from the keyboard and using a pre-existing and known good library instead) then they'll surely make lots of other mistakes (from elementary to subtle) with the cryptography too. Indeed, keeping the standard random number generator not suitable for crypto is a good thing, because its an easy-to-spot marker that indicates that there are likely a whole range of insecurities in the code. Like finding brown M&M's in the bowl. http://www.snopes.com/music/artists/vanhalen.asp

For numerical applications (Monte Carlo) you want deterministic random numbers, but seeded non-deterministically (but with the seed stashed away somewhere, so that you can reproduce the calculation later if necessary).

For a game, it would vary - if its a networked multiplayer game then you may well want it to be deterministic, so that multiple clients can do the same 'dice rolls' and stay in sync. If its an online poker game then you definitely want it to be non-deterministic (but you'd probably get the random numbers from a server somewhere anyway).

In all of these cases you'd want to choose very carefully the random number generator and how its used. No 'default' generator will cover all of these cases. The default generator should only be used for 'throwaway' applications, where you need some randomness but don't care whether its deterministic or secure, as long as it meets some minimum level of quality. And for that, MT is already overkill.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds