skillfed

M2Crypto

A Python crypto and SSL toolkit

m2crypto v0.48.0 264.0K downloads/30d#8,346 on PyPI
Permissive license BSD-2-Clause Active released

What it is and what it does

M2Crypto is a Python wrapper around OpenSSL that exposes cryptographic operations and TLS functionality through a high-level API. It provides RSA, DSA, DH key generation and operations, symmetric ciphers (including AES), HMAC and message digest functions, and full TLS client/server implementation. It also extends Python's standard httplib, urllib, and xmlrpclib with HTTPS support, and includes S/MIME v2 messaging and FTP/TLS capabilities.

The library has been in maintenance mode since 2014 and is actively maintained but explicitly recommended only for existing applications. The maintainer directs new projects toward more modern alternatives. M2Crypto depends only on packaging at runtime and requires OpenSSL headers and a C compiler to install; prebuilt wheels exist for recent Python versions on Windows.

Use it for:

  • Migrate legacy Python applications that already use M2Crypto for TLS and cryptographic operations without rewriting.
  • Implement HTTPS clients or servers when you need direct OpenSSL control and already have M2Crypto in your codebase.
  • Add HMAC-based session management (AuthCookies) to web applications requiring unforgeable authentication tokens.
  • Perform RSA or DSA key generation and cryptographic operations in systems where OpenSSL interoperability is critical.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

M2Crypto wraps OpenSSL via SWIG to provide Python access to cryptographic primitives (RSA, DSA, AES, HMAC), TLS client/server implementation, and HTTPS extensions.

Yes, but with conditions. Install M2Crypto only if you are maintaining existing code that already depends on it or if you need direct OpenSSL interoperability that modern alternatives do not provide. Do not use it for new projects—the maintainer explicitly recommends alternatives instead. Medium install friction (compiled extension) is acceptable for established deployments. No known vulnerabilities and permissive licensing support continued use.

Install

m2crypto on PyPI

pip

pip install m2crypto

uv

uv add m2crypto

poetry

poetry add m2crypto

Installing M2Crypto

Before you install

Medium install friction due to compiled C extension requiring OpenSSL headers and build tools. Active maintenance with recent release (83 days old), though explicitly in maintenance mode since 2014—suitable for existing deployments but new projects should consider alternatives.

License in practice

BSD-2-Clause is permissive; you may use, modify, and distribute M2Crypto freely in commercial and private projects with minimal restrictions.

Quickstart

pip install m2crypto
from M2Crypto import BIO, RSA
key = RSA.gen_key()

Requires OpenSSL development headers and a C compiler; on Windows prebuilt wheels are available for Python 3.10–3.14.

Verify before relying

  • Whether the library's documented memory-leak caveats and lack of key-clearing features pose practical risks for your use case.
  • Current state of the SWIG bindings and whether all OpenSSL features you need are exposed.
  • Specific key generation parameters and their defaults for RSA and DSA operations.

Package facts

License BSD-2-Clause (permissive)
Python support supports the current Python release (>=3.6)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — packaging
Maintenance actively maintained — 83 days since the last release
First released
Downloads 263,997/month — #8,346 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: m2crypto-0.48.0-cp310-cp310-win_amd64.whl; m2crypto-0.48.0-cp311-cp311-win_amd64.whl; m2crypto-0.48.0-cp312-cp312-win_amd64.whl; m2crypto-0.48.0-cp313-cp313-win_amd64.whl; m2crypto-0.48.0-cp314-cp314-win_amd64.whl

Keywords: cryptography, openssl

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Security :: CryptographyTopic :: Software Development :: Libraries :: Python Modules

Tags

python openssl wrappertls ssl client serverrsa dsa encryption pythonhmac message digestcryptography toolkit openssl
openssl-wrapperlegacy-maintenancetls-implementation

More Python Modules packages