MD5()

E

ed18hg

Hello,
I'm using this code to get the MD5 of the numbers 0-9. How can I loop
through the combination of all lowercase letters and 0-9. I read in the
documentation the string operation ascii_lowercase but I'm a bit confused on
how to combine it with integers. Thanks in advance.

for i in xrange(10):
import md5
m=md5.new()
m.update("%i"%i)
print"i=",i,"md5(i)=",m.hexdigest()
 
S

Sam Holden

Hello,
I'm using this code to get the MD5 of the numbers 0-9. How can I loop
through the combination of all lowercase letters and 0-9. I read in the
documentation the string operation ascii_lowercase but I'm a bit confused on
how to combine it with integers. Thanks in advance.

It depends what you mean by "combination of all lowercase letters and 0-9".

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465

shows one way of generating combinations, but what you want depends on
what you are actually trying to do.
for i in xrange(10):
import md5
m=md5.new()
m.update("%i"%i)
print"i=",i,"md5(i)=",m.hexdigest()

If you want all pairs of lowercase letters and 0-9 you could, for example, use:

import string
import md5

def pairs(s):
for c1 in s:
for c2 in s:
yield c1+c2

for i in pairs(string.ascii_lowercase+string.digits):
m = md5.new()
m.update(i)
print "i=",i,"md5(i)=",m.hexdigest()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top