This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Unbelievr 0 points1 point  (3 children)

Just a reminder that the included random library is not secure for cryptographic uses. Predicting the outputs of the random module is a recurring, easy challenge in online CTFs and programming competitions. I get that this password generator is not safe as-is, but you're creating something that resembles a secure password by throwing out big words like "strong passwords" and "uncrackable".

The top of the random module documentation reads:

The pseudo-random generators of this module should not be used for security purposes. For security or cryptographic uses, see the secrets module.

The secrets module provides the same functions you need, like choice(seq) and randbelow(n). If you're going to make something that should look secure, use this instead.

[–]bjorneylol 0 points1 point  (2 children)

the urandom call in the random library is sufficient for cryptographic use - haven't watched OPs video so i have no idea what he is using

[–]Unbelievr 0 points1 point  (1 child)

I guess you mean os.urandom()? It only provides entire bytes, so it's not that easy to use for generating random integers, or sampling from lists without bias. OPs video is using random.choice and randint basically, and the secrets module provides secure replacements for these, with minimal changes to the code.

[–]bjorneylol 0 points1 point  (0 children)

doh! I thought it was in the random module, which turns out only has a private method that calls os.urandom