Reputation: 526
According to the Python documentation, only a few hash algorithms are guaranteed to be supported by the hashlib module (MD5 and SHA***). How would I go about detecting if other algorithms are available? (like RIPEMD-160) Of course, I could try to use it using the RIPEMD-160 example from the documentation, but I'm not sure how it would complain. Would it throw an exception, if yes, which exception?
Upvotes: 1
Views: 528
Reputation: 14081
Just try it in a 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
Upvotes: 4