Skip to content

Instantly share code, notes, and snippets.

@coffeewasmyidea
Created December 20, 2014 10:01
Show Gist options
  • Save coffeewasmyidea/32744e6c52dd175f24b2 to your computer and use it in GitHub Desktop.
Save coffeewasmyidea/32744e6c52dd175f24b2 to your computer and use it in GitHub Desktop.
Simple example of decrypt md5 (slowly)
#!/usr/bin/python
import hashlib
import sys
def decryptMD5(testHash):
s = []
while True:
m = hashlib.md5()
for c in s:
m.update(chr(c))
hash = m.hexdigest()
if hash == testHash:
return ''.join([chr(c) for c in s])
wrapped = True
for i in range(0, len(s)):
s[i] = (s[i] + 1) % 256
if s[i] != 0:
wrapped = False
break
if wrapped:
s.append(0)
print decryptMD5(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment