Hi, I can't seem to figure this out. Here's my objective: I have a value that is an md5 hash and I have a wordlist. I need to md5 the words in the list, then compare them to the given hash, then have the actual word print out. So I figured out how to take the list and md5 the words and get them to print out. Now I need to compare them but when I do this, it's only saving the very last word that was hashed. Here are some things I've tried:
-
import hashlib,string
-
# the given hash, which is actually "12345"
-
x="827ccb0eea8a706c4c34a16891f84e7b"
-
f=open("words.txt","r")
-
words = f.readlines()
-
# my loop to run through the words, converting to md5
-
for word in words:
-
m=hashlib.md5(word)
-
k=m.hexdigest()
-
print k
-
That will successfully print out all of the converted values in the wordlist but now I need to compare it to 'x'.
-
import hashlib,string
-
# the given hash, which is actually "12345"
-
x="827ccb0eea8a706c4c34a16891f84e7b"
-
f=open("words.txt","r")
-
words = f.readlines()
-
# my loop to run through the words, converting to md5
-
for word in words:
-
m=hashlib.md5(word)
-
k=m.hexdigest()
-
# this part only works if the value of 'x' is the very-
-
# last word in the list:
-
if k==x:
-
print "Yes!"
-
Since it's only using the very last value of 'k' I thought I'd try to save all of the converted values to a text file, then open that up and use another 'for' statement:
-
import hashlib,string
-
# the given hash, which is actually "12345"
-
x="827ccb0eea8a706c4c34a16891f84e7b"
-
f=open("words.txt","r")
-
words = f.readlines()
-
# my loop to run through the words, converting to md5
-
for word in words:
-
m=hashlib.md5(word)
-
k=m.hexdigest()
-
infile=open("data.txt","w")
-
out.write(str(k))
-
out.close()
-
infile=open("data.txt","r")
-
lines=infile.readlines()
-
for line in lines:
-
if line == x:
-
print "Item found!"
-
I don't really think it's necessary for me to have to save the values first but even when I try that route it only saves and writes the very last 'k' value, not all of them. So my question is:
How can I get the value of 'x' to compare to every value of 'k'?