This repository has been archived by the owner on Oct 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
/
password-suggester.py
114 lines (55 loc) · 2.33 KB
/
password-suggester.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import random
def insert(s, pos, ch):
return(s[:pos] + ch + s[pos:])
def add_more_char(s, need):
pos = 0
# add 26 letters
low_case = "abcdefghijklmnopqrstuvwxyz"
for i in range(need):
pos = random.randint(0, len(s)-1)
s = insert(s, pos, low_case[random.randint(0,25)])
return(s)
def suggester(l, u, d, s, st):
num = '0123456789'
low_case = "abcdefghijklmnopqrstuvwxyz"
up_case = low_case.upper()
spl_char = '@#$_()!'
pos = 0
if( l == 0 ):
pos = random.randint(0,len(st)-1)
st = insert(st, pos, low_case[random.randint(0,25)])
if( u == 0 ):
pos = random.randint(0,len(st)-1)
st = insert(st, pos, up_case[random.randint(0,25)])
if( d == 0 ):
pos = random.randint(0,len(st)-1)
st = insert(st, pos, num[random.randint(0,9)])
if( s == 0 ):
pos = random.randint(0,len(st)-1)
st = insert(st, pos, low_case[random.randint(0,6)])
return st
def generate_password(n, p):
l = 0; u = 0; d = 0; s = 0; need = 0
suggest = ''
for i in range(n):
if( p[i].islower() ):
l = 1
elif( p[i].isupper() ):
u = 1
elif( p[i].isdigit() ):
d = 1
else:
s = 1
if( (l + u + d + s) == 4):
print("Your Password is Strong")
return
else:
print("Suggested Passwords")
for i in range(10):
suggest = suggester(l, u, d, s, p)
need = 8 - len(suggest)
if(need > 0):
suggest = add_more_char(suggest, need)
print(suggest)
input_string = 'hacktoberfest@2021'
generate_password( len(input_string), input_string)