Python MD5 Cracker "TypeError: object supporting the buffer API required"

Python MD5 Cracker "TypeError: object supporting the buffer API required"

我的代码如下所示:

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() on new you create a list object and not an str; lists do not support the Buffer API. Maybe you were looking for strip()来移除任何trailing/leading白色space?

无论哪种方式,来自 new.strip() 的结果 str(或者 split() 如果你 select 结果列表的一个元素)应该被 编码 因为 unicode 对象必须是 encoded before feeding it to a hashing algorithms' initializer.

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