File tree 1 file changed +6
-5
lines changed
ethical-hacking/password-generator
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 1
1
from argparse import ArgumentParser
2
+ import secrets
2
3
import random
3
4
import string
4
5
34
35
# generate random password with the length
35
36
# of total_length based on all available characters
36
37
passwords .append ("" .join (
37
- [random .choice (string .digits + string .ascii_letters + string .punctuation ) \
38
+ [secrets .choice (string .digits + string .ascii_letters + string .punctuation ) \
38
39
for _ in range (args .total_length )]))
39
40
else :
40
41
password = []
41
42
# If / how many numbers the password should contain
42
43
for _ in range (args .numbers ):
43
- password .append (random .choice (string .digits ))
44
+ password .append (secrets .choice (string .digits ))
44
45
45
46
# If / how many uppercase characters the password should contain
46
47
for _ in range (args .uppercase ):
47
- password .append (random .choice (string .ascii_uppercase ))
48
+ password .append (secrets .choice (string .ascii_uppercase ))
48
49
49
50
# If / how many lowercase characters the password should contain
50
51
for _ in range (args .lowercase ):
51
- password .append (random .choice (string .ascii_lowercase ))
52
+ password .append (secrets .choice (string .ascii_lowercase ))
52
53
53
54
# If / how many special characters the password should contain
54
55
for _ in range (args .special_chars ):
55
- password .append (random .choice (string .punctuation ))
56
+ password .append (secrets .choice (string .punctuation ))
56
57
57
58
# Shuffle the list with all the possible letters, numbers and symbols.
58
59
random .shuffle (password )
You can’t perform that action at this time.
0 commit comments