根据Python文档,只有少量散列算法被保证由Hashlib模块(MD5和SHA ***)支持。如果其他算法可用,我将如何进行检测?(如Ripemd-160)当然,我可以尝试使用文件中的RIPEMD-160示例,但我不确定它会抱怨。如果是,它会抛出异常吗?

有帮助吗?

解决方案

只需在shell中尝试:

>>> h = hashlib.new('ripemd161')                                                                                                                     
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/hashlib.py", line 124, in __hash_new
    return __get_builtin_constructor(name)(string)
  File "/usr/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type ripemd161
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top