import hashlib
import csv
with open ('C:\Python\Test\Hash.csv') as hash_file:
# file_reader = csv.DictReader(hash_file)
file_reader = csv.reader(hash_file)
# counter = 0
mydict = dict(filter(None,csv.reader(hash_file)))
for i in range(1000,10000):
bank_of_hash = hashlib.sha256(str(i).encode()).hexdigest()
bank_of_hash={i:bank_of_hash}
for counter in range(1,11):
# counter +=1
if mydict.values() == bank_of_hash.values():
print("This is your %s hash and this is the $a your decode" %(i,row))
else:
print("Password Not Found!!!")
大家好,首先,谢谢您对我的帮助。其次,它是如此简单,我不知道为什么它不起作用。
1-I导入库。2将其打开为hash_file3-这是我的hash.csv文件
4-我阅读了CSV文件,然后将其转换为字典5-我知道我的哈希值是1000-100006-用键和值制作了一个哈希字典7-I我唯一想做的就是两个字典之间的简单比较。
我已经尝试运行您的代码,但是无法将哈希文件中的数据解析为字典,因此我将代码修改为此并工作:
import hashlib
hash_data = dict()
with open ('C:\Python\Test\Hash.csv') as hash_file:
for line in hash_file.read().split():
hash_data[line.split(',')[0]] = line.split(',')[1]
for i in range(1000,10000):
bank_of_hash = hashlib.sha256(str(i).encode()).hexdigest()
for key in hash_data:
if hash_data[key] == bank_of_hash:
print(key, ':', i)