Python MD5破解器 "TypeError: object supporting the buffer API required"。

15

我的代码如下:

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.")

但是,当我运行它时,我会得到这个错误:

    hs = hashlib.md5(new).hexdigest()
TypeError: object supporting the buffer API required

我该如何解决这个问题?“b”字节?
1个回答

12
无论什么情况,在 new 上调用 split() 会创建一个 list 对象,而不是 str;列表不支持 缓冲区 API。也许你想使用 strip() 来移除任何尾随/前导空格?无论如何,从 new.strip() (或者如果你选择结果列表的元素,则为 split()) 得到的结果 str 应该被 编码,因为 Unicode 对象必须在将其提供给哈希算法的初始化器之前进行 编码
new = new.strip() # or new.split()[index]
hs = hashlib.md5(new.encode()).hexdigest()

'new=new.strip()' 想要删除这些空格,但为什么不起作用呢? - Ahmet
2
如果你正在使用Pandas,那么空值(NaN)可能也会导致这个错误,因此在运行之前你可能需要处理这些值。 - rocksteady

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接