HashLib module does not work in Google Colab no RIPEMD160

185 Views Asked by At

The problem in Google Colab is that the HashLib module is not working properly, several cryptographic algorithms are missing.

enter image description here

I'm running the code:

import hashlib

for name in hashlib.algorithms_available:
    try:
        hashlib.new(name)
        print('ok', name)
    except ValueError:
        print('error', name)

Should be:

enter image description here

How do I configure the RIPEMD160 cryptographic algorithm?

1

There are 1 best solutions below

0
bk2204 On

I don't believe there's any way to change the hash algorithms. The algorithms are dependent on the version of OpenSSL used by your version of Python, and it appears that your version doesn't support RIPEMD-160. As far as I know, Google Colab doesn't allow changing the Python version, so you're kind of stuck with what they're offering.

If you specifically need RIPEMD-160, then you'd need to include a pure Python version, which would be slow, but would probably work. Here's such an implementation, which I found simply by a quick Google search and cannot vouch for in any way. If you can't make use of a pure Python version, then you're out of luck.

Otherwise, I'd recommend sha256, sha384, sha512, sha512-256, or any of the SHA-3 or BLAKE2 options, all of which are solid choices and can be used instead. If you're unsure what to choose, SHA-256 is a good, boring choice. Avoid MD4, MD5, and SHA-1, all of which are weak and should no longer be used.