[Python-ideas] Pre-PEP Adding A Secrets Module To The Standard Library

Chris Angelico rosuav at gmail.com
Sun Sep 20 02:14:02 CEST 2015

On Sun, Sep 20, 2015 at 9:40 AM, Tim Peters <tim.peters at gmail.com> wrote:
>  Token functions
>     .token_bytes(nbytes)
>         another name for os.urandom()
>     .token_hex(nbytes)
>         same, but return string of ASCII hex digits
>     .token_url(nbytes)
>         same, but return URL-safe base64-encoded ASCII
>     .token_alpha(alphabet, nchars)
>         string of `nchars` characters drawn uniformly
>         from `alphabet`

token_bytes "obviously" should return a bytes, and token_alpha equally
obviously should be returning a str. (Or maybe it should return the
same type as alphabet, which could be either?) What about the other
two? Also, if you ask for 4 bytes from token_hex, do you get 4 hex
digits or 8 (four bytes of entropy)?


More information about the Python-ideas mailing list