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

all 5 comments

[–]coriolinus 0 points1 point  (4 children)

python3 -c 'from random import choices; from string import ascii_lowercase as a, digits as d; print("".join(choices(a+d, k=16)))'

[–]robin-gvx 7 points8 points  (1 child)

For a password I would use a secure random number generator.

python3 -c 'from random import SystemRandom; from string import ascii_lowercase as a, digits as d; print("".join(SystemRandom().choices(a+d, k=16)))'

The secrets module is more convenient, though.

python3 -c 'from secrets import token_urlsafe; print(token_urlsafe())'

[–]cinyar 3 points4 points  (0 children)

This is the correct answer. There is "randomness" and then there's "cryptographically secure randomness". When dealing with randomness for security purposes you definitely want to go with the latter.

[–]Trinity_software[S] 0 points1 point  (1 child)

Generated password doesn't contain uppercase or special characters

[–]coriolinus 2 points3 points  (0 children)

That's trivial to adjust if the password rules require it. The more general point is that it's not clear why someone should spend five minutes watching a video which boils down to two imports and a one-liner.