RIPEMD-160 produces the 160 bit digest of a message. For example:
>>> from Crypto.Hash import RIPEMD160 >>> >>> h = RIPEMD160.new() >>> h.update(b'Hello') >>> print h.hexdigest()
RIPEMD-160 stands for RACE Integrity Primitives Evaluation Message Digest with a 160 bit digest. It was invented by Dobbertin, Bosselaers, and Preneel.
This algorithm is not considered secure. Do not use it for new designs.
RIPEMD-160 is vulnerable to length-extension attacks, which are relevant if you are computing the hash of a secret message.
For instance, let’s say you were planning to build a cheap MAC by concatenating a secret key to a public message m (bad idea!):
By only knowing the digest h and the length of m and k, the attacker can easily compute a second digest h’:
where p is a well-known bit string and the attacker can pick a bit string z at will.
A RIPEMD-160 hash object. Do not instantiate directly. Use the
- oid (string) – ASN.1 Object ID
- block_size (integer) – the size in bytes of the internal message block, input to the compression function
- digest_size (integer) – the size in bytes of the resulting hash
Return a copy (“clone”) of the hash object.
The copy will have the same internal state as the original hash object. This can be used to efficiently compute the digests of strings that share a common initial substring.
Returns: A hash object of the same type
Return the binary (non-printable) digest of the message that has been hashed so far.
Returns: The hash digest, computed over the data processed so far. Binary form. Return type: byte string
Return the printable digest of the message that has been hashed so far.
Returns: The hash digest, computed over the data processed so far. Hexadecimal encoded. Return type: string
Create a fresh RIPEMD-160 hash object.
Continue hashing of a message by consuming the next chunk of data.
Parameters: data (byte string/byte array/memoryview) – The next chunk of the message being hashed.