osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

on the prng behind random.random()


On Tue, Nov 20, 2018 at 7:31 AM Robert Girault <r at dev.null> wrote:
> Nice.  So Python's random.random() does indeed use mt19937.  Since it's
> been broken for years, why isn't it replaced by something newer like
> ChaCha20?  Is it due to backward compatibility?  That would make sense.

What exactly do you mean by "broken"? If you're generating random
numbers for any sort of security purpose, you probably should look at
this:

https://docs.python.org/3/library/secrets.html

(New in 3.6, though, hence the "probably". If you need to support 3.5
or older - including 2.7 - then you can't use that.)

ChrisA