File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
ethical-hacking/password-generator Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 11from argparse import ArgumentParser
2+ import secrets
23import random
34import string
45
3435 # generate random password with the length
3536 # of total_length based on all available characters
3637 passwords .append ("" .join (
37- [random .choice (string .digits + string .ascii_letters + string .punctuation ) \
38+ [secrets .choice (string .digits + string .ascii_letters + string .punctuation ) \
3839 for _ in range (args .total_length )]))
3940 else :
4041 password = []
4142 # If / how many numbers the password should contain
4243 for _ in range (args .numbers ):
43- password .append (random .choice (string .digits ))
44+ password .append (secrets .choice (string .digits ))
4445
4546 # If / how many uppercase characters the password should contain
4647 for _ in range (args .uppercase ):
47- password .append (random .choice (string .ascii_uppercase ))
48+ password .append (secrets .choice (string .ascii_uppercase ))
4849
4950 # If / how many lowercase characters the password should contain
5051 for _ in range (args .lowercase ):
51- password .append (random .choice (string .ascii_lowercase ))
52+ password .append (secrets .choice (string .ascii_lowercase ))
5253
5354 # If / how many special characters the password should contain
5455 for _ in range (args .special_chars ):
55- password .append (random .choice (string .punctuation ))
56+ password .append (secrets .choice (string .punctuation ))
5657
5758 # Shuffle the list with all the possible letters, numbers and symbols.
5859 random .shuffle (password )
You can’t perform that action at this time.
0 commit comments