-
Notifications
You must be signed in to change notification settings - Fork 0
/
conventionally_strong_password.py
44 lines (30 loc) · 1.14 KB
/
conventionally_strong_password.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import string as s
from random import choice as c
from random import randint as r
length = int(input('Enter length of required password\n'))
lowercase = [i for i in s.ascii_lowercase]
uppercase = [i for i in s.ascii_uppercase]
symbols = [i for i in s.punctuation]
digits = [i for i in s.digits]
data = [lowercase,uppercase,symbols,digits]
def get_conven_pass():
part1,part2 = '',''
for i in range(length - 4):
a = r(0,3)
b = c(data[a])
part1 += b
for i in range(0,4): # part two of string to ensure
b = c(data[i]) # each category has at least
part2 += b # one element in the password
temp = list(part1)
while (part2 != ''):
t = part2[0] # each character of part2 being
part2 = part2[1:] # added into random positions
temp.insert(r(0,len(temp)), t) # of part1
final = ''
for i in temp:
final += str(i)
return(final)
print('Here are your passwords. choose from the following.\n'.title())
for i in range(0,4):
print(get_conven_pass())