Python MD5 Cracker“TypeError:支持所需缓冲API的对象”

我的代码如下:

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”字节?

最佳答案 无论如何,通过在新的上调用
split(),你创建一个列表对象而不是str;列表不支持
the Buffer API.也许您正在寻找
strip()以删除任何尾随/前导空格?

无论哪种方式,由于unicode对象必须是encoded before feeding it to a hashing algorithms’ initializer,因此应该编码来自new.strip()(或split()的结果str(如果选择结果列表的元素)).

new = new.strip() # or new.split()[index]
hs = hashlib.md5(new.encode()).hexdigest()
点赞