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

Ahm*_*met 7 python md5 python-3.x

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.")
Run Code Online (Sandbox Code Playgroud)

But, I get this error when I run it:

    hs = hashlib.md5(new).hexdigest()
TypeError: object supporting the buffer API required
Run Code Online (Sandbox Code Playgroud)

How do I solve this? "b" bytes?

Jim*_*ard 9

无论是哪种情况,通过调用split()new创建一个list对象,而不是一个str; 列表不支持Buffer API。也许您正在寻找strip()以删除任何尾随/前导空白?

无论哪种方式,都应该对结果strfrom new.strip()(或者split()如果您选择结果列表的元素)进行编码,因为 unicode 对象必须在将其提供给散列算法的初始化程序之前进行编码

new = new.strip() # or new.split()[index]
hs = hashlib.md5(new.encode()).hexdigest()
Run Code Online (Sandbox Code Playgroud)

  • 如果您使用 Pandas,空 (NaN) 值也可能导致此错误,因此您可能需要在运行这些值之前处理它们。 (2认同)