Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Python interface to the MD5 routines of libaprutil

Project description

python-aprmd5 is a Python extension written in C that wraps the MD5 routines of the Apache Portable Runtime (APR) Utility Library (libaprutil) and exposes them to the Python interpreter as the module aprmd5. The main purpose of writing python-aprmd5 in the first place has been to expose the function apr_md5_encode(), which generates salted crypt-style hashes using a version of the MD5 hash algorithm that was modified especially for the APR project.

The resulting hashes always start with the prefix characters “$apr1$” in order to distinguish them from the result of various other crypt() variants, which use other prefixes. For instance, for input “foo” and salt “mYJd83wW”, apr_md5_encode() produces the following hash:


Hashes like this are typically generated by the command line utility htpasswd, which is part of the Apache HTTP server project. The hashes encrypt user passwords that are used by the Apache HTTP server for basic user authentication.

For completeness sake, python-aprmd5 exposes not only apr_md5_encode() but most of the other functions of libaprutil’s MD5 routines as well. Where those functions are concerned with the original, unmodified MD5 algorithm, this is mostly a duplication of effort as that algorithm can be easily obtained through the Python Standard Library module “hashlib”. In fact I advise against using python-aprmd5 if you are interested in the original MD5 algorithm only.

Project details

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page