Skip to content

Commit 4b43a2f

Browse files
authored
Add another randomness into the password generator
Uses import random for namespace cleanliness Uses list instead of string for 'chars' variable in order to shuffle, increases randomness Instead of string formatting, uses string concatenation because (currently) it is simpler
1 parent b56cb26 commit 4b43a2f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

other/password_generator.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import string
2-
from random import *
2+
import random
33

4-
letters = string.ascii_letters
5-
digits = string.digits
6-
symbols = string.punctuation
4+
letters = [letter for letter in string.ascii_letters]
5+
digits = [digit for digit in string.digits]
6+
symbols = [symbol for symbol in string.punctuation]
77
chars = letters + digits + symbols
8+
random.shuffle(chars)
89

910
min_length = 8
1011
max_length = 16
11-
password = ''.join(choice(chars) for x in range(randint(min_length, max_length)))
12-
print('Password: %s' % password)
12+
password = ''.join(random.choice(chars) for x in range(random.randint(min_length, max_length)))
13+
print('Password: ' + password)
1314
print('[ If you are thinking of using this passsword, You better save it. ]')

0 commit comments

Comments
 (0)