对于我的assingment,我应该创建一个预先计算的哈希值从给定字典与盐0到255到每个密码的文件。我有散列,但是当我尝试将它们与给定的影子文件进行比较时,我什么都没有。这导致我相信我可能哈希不正确?我的教授确实说过密码哈希是用C完成的。这是否有所作为?MD5哈希和Python中的比较
这里是我的代码: 找到哈希
import hashlib
f = open('/root/dictionary/dictionary', 'r')
print f
i=0
def getMD5Hash(textToHash=None):
return hashlib.md5(textToHash).hexdigest()
for line in f:
line = line.rstrip()
#print line
i=0
while i <= 255:
j=str(i)
line1 = j+line
md5=getMD5Hash(line1)
print md5,':',line1
i+=1
开裂
f1 = open('/root/dictionary/shadow3','r')
def crack(Hash=None):
f = open('/root/dictionary/HASHES','r')
for line in f:
line = line.rstrip()
line1 = line.split(" ")[0]
if line == Hash:
print (line,"\n",Hash)
return line
for line in f1:
line = line.rstrip()
line = line.split(":")[1:]
print line[0]
result = crack(line[0])
print result
编辑:用我被赋予了阴影RAR文件:http://mediafire.com/?euwjpxr3np36brt
字典文件中给出 - http://mediafire.com/?psspoqo900x0hmq
关闭文件通常是一个好主意。 – 2012-02-03 22:16:09
请确保你的标签在你的代码中是正确的 - 毕竟这是Python :) – 2012-02-03 22:25:28