【发布时间】:2014-11-29 01:34:07
【问题描述】:
我已经用 python 编码了一段时间,并决定制作一个 MD5 暴力破解器。这是我的代码
import hashlib
import sys
import os
import time
import urllib2
import urllib
import re
import string
import random
from itertools import islice
string = raw_input("HASH TO DECRYPT: ")
size = input("PASSWORD LENGTH: ")
char_list = ("a")
def random_char(size):
selection = iter(lambda: random.choice(char_list),object())
while True:
yield ''.join(islice(selection, size))
random_gen = random_char(size)
def encrypt(random_gen):
algorithim = hashlib.md5()
algorithim.update(random_gen)
encrypted=algorithim.hexdigest()
def dosethestringexisit():
if encrypt(random_gen) == string :
print next(random_char)
else:
print("pass not found")
print dosethestringexisit()
我遇到了几个问题,比如这个错误
algorithim.update(random_gen)
TypeError: must be string or buffer, not generator
我不知道如何更改随机生成的字符串以适应 algorithm.update()。
请注意,字符列表只有“a”,因为我使用 md5 哈希“a”只是为了测试代码是否有效。
我还想知道如果随机散列不等于需要解密的散列,如何创建一个while循环来重复代码。非常感谢。
【问题讨论】:
标签: python python-2.7 hash md5