Python MD5 Cracker“TypeError:支持所需缓冲区API的对象”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38175170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python MD5 Cracker "TypeError: object supporting the buffer API required"
提问by Ahmet
My code looks as follows:
我的代码如下所示:
md = input("MD5 Hash: ")
if len(md) != 32:
print("Don't MD5 Hash.")
else:
liste = input("Wordlist: ")
ac = open(liste).readlines()
for new in ac:
new = new.split()
hs = hashlib.md5(new).hexdigest()
if hs == md:
print("MD5 HASH CRACKED : ",new)
else:
print("Sorry :( Don't Cracked.")
But, I get this error when I run it:
但是,当我运行它时出现此错误:
hs = hashlib.md5(new).hexdigest()
TypeError: object supporting the buffer API required
How do I solve this? "b" bytes?
我该如何解决这个问题?“b”字节?
采纳答案by Dimitris Fasarakis Hilliard
Whatever the case, by calling split()
on new
you create a list
object and not an str
; lists do not support the Buffer API. Maybe you were looking for strip()
in order to remove any trailing/leading white space?
无论是哪种情况,通过调用split()
上new
创建一个list
对象,而不是一个str
; 列表不支持Buffer API。也许您正在寻找strip()
以删除任何尾随/前导空白?
Either way, the resulting str
from new.strip()
(or split()
if you select an element of the resulting list) should be encodedsince unicode objects must be encoded before feeding it to a hashing algorithms' initializer.
无论哪种方式,都应该对结果str
from new.strip()
(或者split()
如果您选择结果列表的元素)进行编码,因为 unicode 对象必须在将其提供给散列算法的初始化程序之前进行编码。
new = new.strip() # or new.split()[index]
hs = hashlib.md5(new.encode()).hexdigest()