-
Notifications
You must be signed in to change notification settings - Fork 2
/
simple.py
50 lines (40 loc) · 1.18 KB
/
simple.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
import time
testChars = "abcdefghijklmnopqrstuvwxyz"
#testChars = "0987654321"
#testChars = "abcdefghijklmnopqrstuvwxyz0987654321"
def checkPwForLen(pwLen):
global printCount
generatedPw = [testChars[0]] * pwLen
while generatedPw != [testChars[-1]] * pwLen:
incrementPw(generatedPw)
printCount += 1
if printCount % 10000 == 0:
print('TESTING:', generatedPw)
if generatedPw == pwList:
print('TESTING:', generatedPw)
print('FOUND:', ''.join(generatedPw))
return True
return False
def incrementPw(generatedPw):
incr = 0
while True:
pos = testChars.find(generatedPw[incr])
if pos == len(testChars)-1:
generatedPw[incr] = testChars[0]
incr += 1
if incr > len(generatedPw)-1:
break
else:
generatedPw[incr] = testChars[pos + 1]
break
userPw = input("Enter Password: ")
pwList = list(userPw)
maxPwLen = len(pwList)
printCount = 0
start = time.time()
for i in range(maxPwLen):
if checkPwForLen(i + 1):
break
stop = time.time()
print('DURATION:', stop - start)
print('CHECKED:', printCount)