Python 在txt文件中逐行导入的哈希值不正确
我正在做一个小的字典杂凑饼干。 我知道我需要多重处理,但我现在只是在测试它。 我的问题不是我犯了错误;我的字典文件中的密码(或关键字)没有正确地散列Python 在txt文件中逐行导入的哈希值不正确,python,python-3.x,encryption,md5,hashlib,Python,Python 3.x,Encryption,Md5,Hashlib,我正在做一个小的字典杂凑饼干。 我知道我需要多重处理,但我现在只是在测试它。 我的问题不是我犯了错误;我的字典文件中的密码(或关键字)没有正确地散列 import hashlib print(" _ _ _ ") print("| | | | | | ") print("| |__ __ _ _
import hashlib
print(" _ _ _ ")
print("| | | | | | ")
print("| |__ __ _ ___| |__ ___ _ __ __ _ ___| | _____ _ __ ")
print("| '_ \ / _` / __| '_ \ / __| '__/ _` |/ __| |/ / _ \ '__|")
print("| | | | (_| \__ \ | | | | (__| | | (_| | (__| < __/ | ")
print("|_| |_|\__,_|___/_| |_| \___|_| \__,_|\___|_|\_\___|_| ")
print("")
print("Made By IronKey | python 3.7 ")
hashed = input("ENTER YOUR PASSWORD TO RECOVER: ")
wordlist = input("enter your dictionary: ")
print("")
with open(wordlist) as passList:
for i in passList:
hash1 = hashlib.md5(i.encode())
hash1.hexdigest()
print(hash1.hexdigest())
if str(hash1.hexdigest()) == str(hashed):
print("password is cracked: " + i)
break
print("")
input("press enter to leave")
导入hashlib
打印(“打印”)
打印(“| | | | | |”)
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
打印(“|”|/|/|/|/|/|/|/|/|/|/|”)
打印(“| | | | | | | | | | | | | | | |<|/|”)
打印(“|u124; u124; u124;|u124; uuuuuuuuuuuuuuuuu/|u124; u124; uu124;|uuuuuuuuuuu124; | | | | | | | | | | | | | | | | | | | | | | |
打印(“”)
打印(“由IronKey | python 3.7制作”)
hashed=input(“输入要恢复的密码:”)
wordlist=输入(“输入您的字典:”)
打印(“”)
以open(wordlist)作为密码列表:
对于passList中的i:
hash1=hashlib.md5(i.encode())
hash1.hexdigest()
打印(hash1.hexdigest())
如果str(hash1.hexdigest())==str(散列):
打印(“密码被破解:+i”)
打破
打印(“”)
输入(“按回车键离开”)
输入示例:b81e70651fb13d7d7051cc1684c0f91e(密码234的哈希)
输出示例(如果Passowrd234在字典文件中):密码已破解:Password234
实际输出:Password234的哈希值完全不同,它返回的比较结果是错误的!请提供一个示例输入,其中包含相应的预期输出和实际输出。
对于passList中的i
-i
仍然在此处有其尾随换行符。请尝试hash1=hashlib.md5(i.strip().encode())
也可能为passfile中的行选择一个更具描述性的名称?或其他什么?同样值得注意的是hash1.hexdigest()
和hashed
都是字符串——在比较之前不必将它们转换为字符串。这非常感谢@AdamSmith完全起作用