python - MD5 Cracker not working python3 -


md = input("md5 hash: ") if len(md) != 32:     print("don't md5 hash.") else:     liste = input("wordlist: ")     ac = open(liste).readlines()     new in ac:         hs = hashlib.md5(new.encode()).hexdigest()         if hs == md:             print("md5 hash cracked : ", new)      print("sorry :( don't cracked.") 

executing not working. wordlist:

sadasda asdasda sdasd da sdasd asd ahmet asdasf knknkjnbhb klasda 

output:

md5 hash: cdb5efc9c72196c1bd8b7a594b46b44f wordlist: md.txt sorry :( don't cracked. 

where did mistake? can't see. wordlist if only:

ahmet 

output:

md5 hash: cdb5efc9c72196c1bd8b7a594b46b44f wordlist: md.txt md5 hash cracked :  ahmet sorry :( don't cracked. 

the lines file include newline. newline significant:

>>> hashlib import md5 >>> md5(b'ahmet').hexdigest() 'cdb5efc9c72196c1bd8b7a594b46b44f' >>> md5(b'ahmet\n').hexdigest() 'ac5bd810592f14278b5e06fc20d88c23' 

remove newline first:

hs = hashlib.md5(new.rstrip('\n').encode()).hexdigest() 

rather have python decode file lines, encode again, open file in binary mode. can loop on file directly, no need call fileobj.readlines() here:

with open(liste, 'rb') ac:     line in ac:         line = line.rstrip(b'\n')         hs = hashlib.md5(line).hexdigest()         if hs == md:             print("md5 hash cracked : ", line.decode('utf8')) 

i've added decoding of line too, printing.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -