0

what us wrong with this code 🤔

import time import string import hashlib ready = False start = time.monotonic() chars = list(string.printable)[:95] base = len(chars) n = 0 hashmethod = 0 password = "" solved = False quit = "" while not ready: password = input("Enter a valid MD5 or SHA-1 hash: ") if len(password) == 32: ready = True elif len(password) == 40: ready = True hashmethod = 2 def numberToBase(n, b): digits = [] while n: digits.append(int(n % b)) n //= b return digits[::-1] if password == '': print('Your password is empty') solved = True while not solved: lst = numberToBase(n, base) word = ''.join([chars[x] for x in lst]) if hashmethod == 2: hashedGuess = hashlib.sha1(word.encode('utf-8')).hexdigest() else: hashedGuess = hashlib.md5(word.encode('utf-8')).hexdigest() if password == hashedGuess: solved = True print('-Stats-') print('Pass: ' + word) print('Attempts: ' + str(n)) print('time: ' + str((time.monotonic() - start)) + ' sec') while quit != "QUIT": quit = input('Type <QUIT> to quit: ').upper() else: n += 1

11th Mar 2023, 12:46 AM
ANAS IL CAPO
ANAS IL CAPO - avatar
1 Respuesta
+ 4
This will not work properly on Sololearn because you are taking input in an endless loop. Interactive code like this, is not suitable for this platform. Apart from that, I cannot tell if it has any particular issues, you never mentioned any specific error, and you didn't describe what you expect your program to do.
11th Mar 2023, 4:10 AM
Tibor Santa
Tibor Santa - avatar