Issue
When I try to use ripemd160
with hashlib
it says it can't find it.
I used easy_install hashlib
which installed hashlib but it still can't find ripemd160.
I'm using Ubuntu and python2.7
def hexHash(str, withHash = None):
h = hashlib.new('ripemd160')
h.update(str)
if withHash != None:
return h.hexdigest()[0:6]
else:
return '#'+h.hexdigest()[0:6]
ValueError: unsupported hash type
Solution
Hashlib is part of Python's standard library, so you don't have to install it.
However, the only hash algorithms that are guaranteed to be available are md5, sha1, sha224, sha256, sha384, and sha512.
Others may be available depending on the SSL library that is used on your platform.
You can run openssl list-message-digest-algorithms
in a terminal to see which algorithms are available.
(Note: as of openssl 1.1.1, the above command doesn't work. Try openssl dgst -list
)
The above assumes that Python uses the system's SSL library, which might not be the case.
Or (better) from Python:
import hashlib
print(hashlib.algorithms_available)
If ripemd160
isn't available, you should probably look into re-installing your SSL library with different options. (Assuming Python uses the system's SSL)
If you are changing your SSL library to one with a different version number, you will have to rebuild anything that depends on it as well.
Answered By - Roland Smith Answer Checked By - Gilberto Lyons (WPSolving Admin)