[英]Python Error: AttributeError: 'builtin_function_or_method' object has no attribute
I'm getting this error: 我收到此错误:
Traceback (most recent call last):
File "crack.py", line 12, in <module>
filemd5 = md5.new(password.strip()).hexdigest()
AttributeError: 'builtin_function_or_method' object has no attribute 'new'
I'm trying to fix but i can't 我正在尝试修复,但无法
Here is my code: 这是我的代码:
from hashlib import md5
for password in pwfile:
filemd5 = md5.new(password.strip()).hexdigest()
That's because md5
is, as the error says, a function of the hashlib
module 正如错误所言,这是因为
md5
是hashlib
模块的功能
>>> from hashlib import md5
>>> type(md5)
<class 'builtin_function_or_method'>
I guess what you want to do is the following: 我想您要执行以下操作:
>>> h = md5() # Returns a hash object.
>>> h.update(password) # Make sure password is a bytes object.
>>> h.hexdigest()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.