【发布时间】:2016-02-17 19:48:30
【问题描述】:
我正在尝试编写一个小 Python 脚本来散列一些单词。我正在使用 hashcat 来验证我的输出,但出了点问题,这应该是一个非常简单的过程。但我无法确定我做错了什么。只有我的输出的最后一个散列得到正确散列。在我的示例文件中使用“123456”作为 5 行的测试时,我得到以下输出:
f447b20a7fcbf53a5d5be013ea0b15af
f447b20a7fcbf53a5d5be013ea0b15af
f447b20a7fcbf53a5d5be013ea0b15af
f447b20a7fcbf53a5d5be013ea0b15af
e10adc3949ba59abbe56e057f20f883e
有人可以指出我的方式的错误。将不胜感激。
import hashlib
my_file = open("sample.txt" , "r")
for line in my_file:
try:
hash_object = hashlib.md5(line)
print(hash_object.hexdigest())
except:
print "Error"
my_file.close()
【问题讨论】:
-
如果
123456的MD5和123456\n的另一个MD5。
标签: python encryption hash md5 sha1