-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword1.py
57 lines (44 loc) · 1.07 KB
/
password1.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
###### Import ########
import hashlib
import time
###### Variable ######
# Dico
d1 = {}
d2 = {}
# File
dico = "./dict.txt"
user = "./hashedPasswordFile.txt"
###### Function ######
def s256(word):
word = bytes(word.strip(),"UTF-8")
word = hashlib.sha256(word).hexdigest()
return word
###### Program #######
if dico and user:
with open(dico, 'r') as file:
for word in file:
h = s256(word)
d1[h] = word.strip()
with open(user, 'r') as file:
for line in file:
line = line.strip()
h = line.split(" ")
for i in h:
if len(i) == 0:
continue
elif len(i) == 64 :
a = i
elif len(i) != 0 :
b = i
d2[a] = b
else:
print("Fichier absent à la racine du programme !!!")
time.sleep(5)
exit(1)
for h2 in d2.keys():
for h1 in d1.keys():
if h2 == h1:
print("Password : {0:9} = Hash : {1}".format(d1[h1], h1))
exit(0)