[Python-ideas] Pre-PEP Adding A Secrets Module To The Standard Library
Random832
random832 at fastmail.com
Tue Sep 22 14:51:10 CEST 2015
On Tue, Sep 22, 2015, at 08:03, Nick Coghlan wrote:
> Building a password from an alphabet is different, as that involves
> repeated applications of secrets.choice() to the given alphabet, so
> you need to specify the result length directly.
Well, in principle, the length could be calculated from the number of
bytes of entropy desired by using
ceil(nbytes*log(256)/log(len(alphabet))), if all that matters is to
"fail safe" [i.e. longer] rather than to not be surprising. Being
calculated by repeated application of choice rather than some other
algorithm is an implementation detail.
More information about the Python-ideas
mailing list