-2
嗨當我選擇選項我alaways得到這個錯誤NameError:名字 'SHA1' 沒有定義
回溯(最後最近一次調用): 文件 「ran.py」 26行,在 SHA1() NameError:名字「SHA1」沒有定義 但我不知道是什麼問題,是我打過電話之前,把功能,但總是同樣的事情
def main():
print '1 - SHA1 Decrypter'
print '2 - MD5 Decrypter'
select = input("select option :")
if select==1:
sha1()
elif select==2:
md5()
def sha1():
try:
sha1 = raw_input("\t\n\nMD5 Hash:")
dictionary = open("pwds.txt","r")
except(IOError):
print "pwds.txt not found!"
for passwd in dictionary.read().split('\n'):
if hashlib.sha1(passwd).hexdigest() == sha1:
print("\n\t[OK]"+sha1+" : "+passwd+"\n")
raw_input("Decrytion Success; Press Enter To Exit")
else:
print "\n\tFailed; Password not found in dictionary"
main()
def md5():
try:
md5 = raw_input("\t\n\nMD5 Hash:")
dictionary = open("pwds.txt","r")
except(IOError):
print "pwds.txt not found!"
for passwd in dictionary.read().split('\n'):
if hashlib.md5(passwd).hexdigest() == md5:
print("\n\t[OK]"+md5+" : "+passwd+"\n")
raw_input("Decrytion Success; Press Enter To Exit")
else:
print "\n\tFailed; Password not found in dictionary"
main()
main()
請修復您的縮進。 – senshin
您需要在調用之前定義該功能。此外,你似乎正在使用一個名爲'''sha1'''的變量。不要這樣做! – wnnmaw