这是我在 Python 中尝试过的代码,但出现了 AttributeError
:
>>> import hmac
>>> import hashlib
>>> h=hashlib.new('ripemd160')
>>> hmac.new("bedford","Hello",hashlib.ripemd160)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'hashlib' has no attribute 'ripemd160'
我搜索了 Python 文档和很多论坛,但没有找到太多关于ripemd160 和 Python 的信息。
最佳答案
ripemd160
不受 hashlib
模块直接支持:
>>> hashlib.algorithms
A tuple providing the names of the hash algorithms guaranteed to be supported by this module.
该模块支持以下内容:md5、sha1、sha224、sha256、sha384、sha512
因此您需要再次使用 new
构造函数或将引用传递给已创建的构造函数。
关于python - 使用自定义 key 和算法ripemd160创建哈希值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37627879/