Generate MD4 Hash using Python

pycryptodome package

  1. Install pycryptodome package from the command line:
pip install pycryptodome
  1. Generate MD4 hash:
from Crypto.Hash import MD4

text = 'Hello'
hashObject = MD4.new(text.encode('utf-8'))
digest = hashObject.hexdigest()

print(digest)

hashlib library

import hashlib

text = 'Hello'
hashObject = hashlib.new('md4', text.encode('utf-8'))
digest = hashObject.hexdigest()

print(digest)

Note: MD4 hash function availability in hashlib library depends on OpenSSL library that Python uses on specific platform. In OpenSSL 3, MD4 is marked as legacy and not available by default.

Leave a Comment

Cancel reply

Your email address will not be published.