python - Python crypt() 脚本无法正确编译
问题描述
知道为什么这不能正确编译吗?
它应该将计算的_salt_hash 与加密的密码进行比较,如果它们匹配,那么它将打印匹配的单词。目前有错误AttributeError: 'list' object has no attribute 'strip'
。如何完成代码,以便向我显示匹配的单词?
(如果在我的程序中没有正确缩进,请忽略)
import crypt
with open("PWD", 'r') as passwd, open("dictionary", 'r') as wordfile:
file = passwd.readlines()
lines = wordfile.readlines()
for i in file:
salt_hash = file.strip()
salt = salt_hash[0:2]
for line in lines:
word = line.strip()
calculated_salt_hash = crypt.crypt(word, salt)
if calculated_salt_hash == salt_hash:
print("Found:", word)
break
解决方案
推荐阅读
- android - Firebase Firestore 查询帮助 android stuido java
- java - 使用 StAX 验证 XML 时尝试从自定义错误处理程序抛出自定义异常时出现问题
- file - 有没有办法与 ssh 云终端共享文件?
- wordpress - wordpress 用户注册表格或联系表格 7
- go - 从 url 获取空参数
- r - 层次聚类 - 查找每个组中的观察值
- python-3.6 - ParseError:第 5 行的错误输入
- c# - 错误:“找不到从 dbcontext 派生的可构造类型”(Visual Studio 2019 和 EF 6 工具)
- php - 旋转jpeg的PHP函数只工作一次
- python - 在 python 中使用 read_sql 时的数据类型转换