algorithm provided by OpenSSL
suggest changeA generic new() constructor that takes the string name of the desired algorithm as its first parameter also exists to allow access to the above listed hashes as well as any other algorithms that your OpenSSL library may offer. The named constructors are much faster than new() and should be preferred.
Using new() with an algorithm provided by OpenSSL:
>>> h = hashlib.new('ripemd160')
>>> h.update("Nobody inspects the spammish repetition")
>>> h.hexdigest()
'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
On Python 3, update() requires a bytes-like object, so this str raises TypeError. With the same text encoded as bytes, ripemd160 is available in this build and the hexadecimal digest matches the transcript.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents