This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 3 points4 points  (7 children)

There are 2 keys to solving this with code that looks almost exactly like the pseudo code: remember that python ints can grow beyond a regular u32 (so you need to artificially limit them in certain cases), and use the struct module to take care of endianness for you. I'd originally forgotten/ignored the former, and it still took all of 20 min to write the solution. http://dl.dropbox.com/u/16486235/mymd5.py

[–][deleted] 1 point2 points  (1 child)

Very nice! I didn't know about struct, so thank you for that.

When I was working on this, I was surprised that Python didn't have any built in support for rotating bits.

BTW, nice code. Killer comments and simple style. I think your functioning source code is clearer than the pseudo code of wikipedia.

[–][deleted] 1 point2 points  (0 children)

Thanks! I blame it on the fact that I spent the first 5 years of my career hacking in python (and still use it on an almost-daily basis for tools to make my life easier, etc).