-3

This is my code:

def checking():

  response2 = requests.get('https://www.nitrxgen.net/md5db/' + str(word[1])).text  

  if response2:
   print(Fore.GREEN + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.GREEN + "]" + Fore.WHITE + " |" + Fore.GREEN + " ■ " + Fore.WHITE +
    "Hash Found: " + Fore.GREEN + response2 + Style.RESET_ALL + "\n", end='')

  else:
   print(Fore.RED + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.RED + "]" + Fore.WHITE + " |" + Fore.RED + " ■ " + Fore.WHITE +
    "Hash Not Found" + Style.RESET_ALL + "\n", end='')

def Mutiple():

  Tk().withdraw() 
  filename = askopenfilename(title='Choose a File', filetypes=[("Text Files", "*.txt")])
  clear = lambda: os.system('cls')
  clear() 
  with open(filename, "r", encoding="utf8") as file:  
    for line in file:
        word = line.strip()
        word = word.split(":")
        return checking()

And the error code is

Traceback (most recent call last):   
  File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 111, in <module>
    Mutiple()   
  File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 40, in Mutiple
    return checking()   
  File "C:\Users\tosun\OneDrive\Desktop\Hashkiller\Hashkiller.py", line 18,  in checking
    response2 = requests.get('https://www.nitrxgen.net/md5db/' + str(word[1])).text 
NameError: name 'word' is not defined
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
GoekhanDev
  • 326
  • 2
  • 4
  • 20
  • Is the `return` statement really supposed to be inside the `for` loop? It will only process the first line of the file. – Barmar Dec 31 '19 at 22:10
  • Also, `checking()` doesn't return anything. What is `return checking()` supposed to return? – Barmar Dec 31 '19 at 22:11
  • The given "duplicate" is a bit of overkill for this problem, but I hope it will resolve your problem, and several more you might have had. – Prune Dec 31 '19 at 22:31

1 Answers1

1

word is a local variable in Mutiple(). If you want to use it in checking(), you should pass it as a parameter.

def checking(word):

  response2 = requests.get('https://www.nitrxgen.net/md5db/' + str(word[1])).text  

  if response2:
   print(Fore.GREEN + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.GREEN + "]" + Fore.WHITE + " |" + Fore.GREEN + " ■ " + Fore.WHITE +
    "Hash Found: " + Fore.GREEN + response2 + Style.RESET_ALL + "\n", end='')

  else:
   print(Fore.RED + "[" + Fore.WHITE + strftime("%H:%M:%S")+ Fore.RED + "]" + Fore.WHITE + " |" + Fore.RED + " ■ " + Fore.WHITE +
    "Hash Not Found" + Style.RESET_ALL + "\n", end='')

def Mutiple():

  Tk().withdraw() 
  filename = askopenfilename(title='Choose a File', filetypes=[("Text Files", "*.txt")])
  clear = lambda: os.system('cls')
  clear() 
  with open(filename, "r", encoding="utf8") as file:  
    for line in file:
        word = line.strip()
        word = word.split(":")
        return checking(word)
Barmar
  • 741,623
  • 53
  • 500
  • 612