MD4

MD4 is specified in RFC1320 and it produces the 128 bit digest of a message. For example:

>>> from Crypto.Hash import MD4
>>>
>>> h = MD4.new()
>>> h.update(b'Hello')
>>> print(h.hexdigest())

MD4 stand for Message Digest version 4, and it was invented by Rivest in 1990.

Warning

This algorithm is not considered secure. Do not use it for new designs.

class Crypto.Hash.MD4.MD4Hash(data=None)

Class that implements an MD4 hash

block_size: int = 64

The internal block size of the hash algorithm in bytes.

copy()

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.

Return:

A hash object of the same type

Return type:

MD4Hash

digest()

Return the binary (non-printable) digest of the message that has been hashed so far.

This method does not change the state of the hash object. You can continue updating the object after calling this function.

Return:

A byte string of digest_size bytes. It may contain non-ASCII characters, including null bytes.

Return type:

bytes

digest_size: int = 16

The size of the resulting hash in bytes.

hexdigest()

Return the printable digest of the message that has been hashed so far.

This method does not change the state of the hash object.

Return:

A string of 2* digest_size characters. It contains only hexadecimal ASCII digits.

Return type:

str

oid: str = '1.2.840.113549.2.4'

ASN.1 Object ID

update(data)

Continue hashing of a message by consuming the next chunk of data.

Repeated calls are equivalent to a single call with the concatenation of all the arguments. In other words: :rtype: None

>>> m.update(a); m.update(b)

is equivalent to:

>>> m.update(a+b)
Parameters:
databyte string/byte array/memoryview

The next chunk of the message being hashed.

Crypto.Hash.MD4.block_size: int = 64

The internal block size of the hash algorithm in bytes.

Crypto.Hash.MD4.digest_size: int = 16

The size of the resulting hash in bytes.

Crypto.Hash.MD4.new(data=None)

Return a fresh instance of the hash object.

Parameters:
databyte string/byte array/memoryview

The very first chunk of the message to hash. It is equivalent to an early call to MD4Hash.update(). Optional.

Return:

A MD4Hash object

Return type:

MD4Hash