Logic
There are different lists with different function names in each of them like this:
md5 = [gamma, alpha, beta, theta, delta] sha1 = [alpha, beta, theta, delta] sha256 = [alpha, beta, theta] sha384 = [alpha, beta, theta] sha512 = [alpha, beta, theta] That means, if a function for is to call md5 list, then all the functions inside the md5 list will run.
One of these lists will be called according to a dictionary of list. But in order to determine which list of functions to take, there is a dictionary created like this:
hashdict = {} hashdict['md5'] = [ 'md5' , 32 , md5 ] hashdict['sha1'] = [ 'sha1' , 40 , sha1 ] hashdict['sha256'] = [ 'sha256' , 64 , sha256 ] hashdict['sha384'] = [ 'sha384' , 96 , sha384 ] hashdict['sha512'] = [ 'sha512' , 128 , sha512 ] Function
This function takes the hash submitted by the user, checks if the string length macthes the length in any dictionary lists inside hashdict{}. If the length matches for example: 32 characters, then it will be md5 hash.
After the script knows the correct list in the dictionary, it will take the function (the third list item - second index of the list) from the perticular list in hashdict and pass it into a function call named api.
def crack(hashvalue): result = False hashInDict = False for hashList in list(hashdict.values()): if len(hashvalue) in hashList: hashInDict = True if not file: print(f'{info} Hash Function : {hashList[0].upper()}') for api in hashList[2]: r = api(hashvalue, hashList[0]) if r: return r else: if hashInDict == False: if not file: print(f'{bad} This hash type is not supported.') quit() else: return False Problem
It works only if the hash is md5 and any other hash passed results in the message "This hash type is not supported". Somehow. if I remove the dictionary and use if-else instead to compare the hash string length, it all works fine. But using dictionary lists has resulted in all other hashes ignored and only the first dicitionary list working.
If I replace the first dictionary list with for example sha1, then only sha1 hashes will be detected and all others will result in hash not supported print.
I have no idea why it's ignoring anything after the first dictionary list item.
hashdict? Please provide all relevant code, there seems to not be enough here to make a logical assumption as to what's going on and what expected result is supposed to be. Also, you can't "call" a list... What do you mean by this?