嗨,当我选择选项时,我会得到这个错误
追踪(最近一次通话): 文件“ran.py”,第26行,in 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()
答案 0 :(得分:0)
代码中有多个错误
import hashlib
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")
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()
except(IOError):
print "pwds.txt not found!"
def md5():
try:
md5 = raw_input("\t\n\nMD5 Hash:")
dictionary = open("pwds.txt","r")
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()
except(IOError):
print "pwds.txt not found!"
main()