python - Python程序意外停止
问题描述
该程序是关于python中的哈希破解器。它基本上会遍历一个巨大的密码列表,然后对每个密码进行 md5 哈希并将其与我的哈希进行比较。它工作得很好,除非我在密码列表中输入超过第 4750 行的密码。它停在那里,程序结束,我不知道为什么。
这是我的代码
import os
try:
import hashlib
except ModuleNotFoundError:
os.system('pip3 install hashlib')
import hashlib
def test_hash(target, string):
hashed = hashlib.md5(string.encode('utf-8')).hexdigest()
if target == hashed:
print(f'Found coincidence at -> {string}')
return 1
else:
return 0
target_hash = 'an-md5-hash'
if __name__ == '__main__':
with open('passwordlist.txt', 'r') as file:
count = 1
while (line := file.readline().rstrip()):
print(f'Trying passord {count} -> {line}')
count += 1
result = test_hash(target_hash, line)
if result == 1:
break
else:
continue
解决方案
文件中一定有问题,可能是错误的行格式。我建议您在发生错误的行检查文件。
推荐阅读
- python - 在python中将固定点转换为浮点数的问题
- google-apps-script - 每次都不会记住并运行外部函数的代码
- javascript - Vuetify 如何在 v-btn 中获取工作链接
- c++ - 通过基类引用参数返回派生对象
- c# - OpenIddict ASP.NET Core 服务器不能用作默认方案处理程序
- python - 根据列值将单列拆分为两列
- assembly - 最快的轮询循环 - 如何修剪 1 个 CPU 周期?
- python - 解析 Content-Disposition 标头的可靠方法
- spring - Spring 按参数名称自动装配不适用于 FtpMessageHandlerSpec
- perl - 命令输出中的两行到一行,我可以冻结 FH 吗?