python - 提高 python sha1 hash bruteforcer 的性能
问题描述
我正在使用 python 中的 sha1 和 base64 制作我的自定义哈希暴力破解器。但是,它的工作速度非常慢。我阅读了我可以使用的三个模块:threading、concurrent.future 和 multiprocessing。有人能说出我应该使用的这些之间的区别,以及为什么其他的不如所选的吗?另外,请告诉我我能做些什么来加快这段代码的速度。这是代码:
import time
import hashlib
import itertools
charset = "abcdefghijklmnopqrstuvwxyz0123456789"
good = "" #here I supply the hash
start = time.time()
def encrypt(password):
hsah = hashlib.sha1(password).digest()
hsah = hsah.encode("base64")[:-1] + "" #here I have something like 'salt' which is needed
hsah = hashlib.sha1(hsah).hexdigest()
if hsah == good:
print "password found!", password
end = time.time()
roz = end - start
print roz
exit()
passwords = itertools.product(charset, repeat=7)
for password in passwords:
encrypt("".join(password))
解决方案
推荐阅读
- pdfhtml - 使用 .print() 从 html 创建下载多页 pdf
- r - 无法在 ggplot2 中为同一功能组合颜色和形状图例
- excel - 对于 VBA Excel 中的每个循环
- mongodb - 无法启动 mongoDB 服务
- java - Spring没有找到符号@QueryResult
- python - Python pptx合并表行
- for-loop - 如何使脚本影响 Roblox LUA 中的所有子级?
- javascript - 我们如何使用 Puppeteer、黄瓜和 JS (npm) 实现浏览器的单例使用
- java - AWS API Gateway WebSocket 错误:意外响应:HTTP/1.1 101 切换协议
- linux - 使用 xbindkeys 鼠标中键单击