【问题标题】:Python MD5 Cracker "TypeError: object supporting the buffer API required"Python MD5 破解器“TypeError:需要支持缓冲区 API 的对象”
【发布时间】:2016-11-05 14:56: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”个字节?

【问题讨论】:

    标签: python python-3.x md5


    【解决方案1】:

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

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

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

    【讨论】:

    • 'new=new.strip()' 删除这些空间但不起作用,为什么?
    • 如果您使用的是 Pandas,具有 null (NaN) 值也会导致此错误,因此您可能需要在运行它们之前处理这些值。
    猜你喜欢
    • 2021-10-15
    • 2019-05-25
    • 2021-05-16
    • 2018-11-11
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-26
    • 2014-08-09
    相关资源
    最近更新 更多