# MD2

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

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

MD2 stand for Message Digest version 2, and it was invented by Rivest in 1989.

Warning

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

class Crypto.Hash.MD2.MD2Hash(data=None)

  An MD2 hash object. Do not instantiate directly. Use the `new()` function.

  Variables:

    - 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

  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.

    Returns:

      A hash object of the same type

  digest()

    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

  hexdigest()

    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

  update(data)

    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.

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

  Create a new hash object.

  Parameters:

    data (bytes/bytearray/memoryview) – Optional. The very first chunk of the message to hash. It is equivalent to an early call to `MD2Hash.update()`.

  Return:

    A `MD2Hash` hash object