Registry / auth-security / pycrypto

pycrypto

JSON →
library2.6.1pypypiunverified

PyCrypto is a collection of cryptographic modules for Python, providing algorithms like AES, RSA, and hashing functions. Its last release was 2.6.1 in 2013. The library is unmaintained and is considered insecure for modern applications due to known vulnerabilities and lack of updates. Its development has ceased, with `pycryptodome` serving as its actively maintained successor and drop-in replacement.

pip install pycrypto
INSTALL
IMPORT
SIG · PYCRYPTO
P
pycrypto
auth-securitypythonv2.6.1
Install
—
Import
—
Disk
—
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AES
✓ from Crypto.Cipher import AES
RSA
✓ from Crypto.PublicKey import RSA
MD5
✓ from Crypto.Hash import MD5
Python 3 compatibility
✓ from Cryptodome.Cipher import AES # For pycryptodome
✗ from Crypto.Cipher import AES # For pycrypto with Python 3
The original PyCrypto (v2.6.1) has very limited and problematic Python 3 support, often leading to installation issues or runtime errors. Use `pycryptodome` for Python 3 compatibility.

This quickstart demonstrates how to compute an MD5 hash using PyCrypto. Please be aware that PyCrypto is an unmaintained library with known security vulnerabilities. MD5 itself is cryptographically broken and should not be used for security-critical purposes. For new projects, `pycryptodome` or `cryptography` are recommended secure alternatives.

from Crypto.Hash import MD5 import os # Note: PyCrypto is an abandoned library and not recommended for new projects # due to security concerns. This example is for illustrative purposes only. # For production, use pycryptodome or cryptography. try: message = b"This is a test message to hash." # Create an MD5 hash object hasher = MD5.new() hasher.update(message) print(f"Original message: {message}") print(f"MD5 hash (hex): {hasher.hexdigest()}") # Important security note: MD5 is cryptographically broken and should NOT # be used for security-critical applications like password storage or digital signatures. except ImportError: print("PyCrypto is not installed or unable to import modules. Please ensure 'pip install pycrypto' was successful and check Python version compatibility.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingPyCrypto is not actively maintained and has known security vulnerabilities, including side-channel attacks and issues with various primitives. Its usage is highly discouraged for any new or security-sensitive applications.
fix
Migrate to `pycryptodome` (a drop-in replacement with identical API) or `cryptography` for secure, actively maintained cryptographic functionalities.
affects: All versions, especially 2.6.1
gotchaOfficial PyCrypto (v2.6.1) has limited and problematic Python 3 support. Installation often fails on modern Python environments and requires system-level build dependencies (like `gcc`, `python-dev`, `build-essential`) that might not be present by default.
fix
For Python 3, use `pycryptodome` which is Python 3 native and provides the same API. If forced to use PyCrypto in Python 3, consider specific forks or patched versions, and ensure all necessary build tools are installed.
affects: All versions (especially when used with Python 3.x)
deprecatedPyCrypto is considered an abandoned library; its last release was in 2013. Its APIs are outdated compared to modern cryptographic practices, and it lacks support for newer, more secure algorithms and modes.
fix
Transition to modern, actively maintained libraries like `pycryptodome` or `cryptography` for current and future projects to ensure security and access to up-to-date cryptographic standards.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'Crypto'
The 'pycrypto' library, or its modern successor 'pycryptodome', is not installed, or there is a conflict between existing installations causing the 'Crypto' namespace to not be found.
fix
Uninstall any potentially conflicting packages (e.g., `pip uninstall pycrypto crypto pycryptodome`) and then install the actively maintained replacement: `pip install pycryptodome`.
error: command 'gcc' failed with exit status 1
PyCrypto requires a C compiler and Python development headers for compilation during installation, which are often missing, especially on Windows or minimal Linux environments. Another related error is 'src/config.h: No such file or directory'.
fix
On Debian/Ubuntu, install `build-essential` and `python3-dev` (or `python-dev` for Python 2) with `sudo apt-get install build-essential python3-dev`. On Windows, install Microsoft Visual C++ Build Tools. As PyCrypto is unmaintained, switching to `pycryptodome` is highly recommended, as it often provides pre-built wheels that bypass compilation issues.
ImportError: cannot import name _AES from Crypto.Cipher
This error occurs when the underlying C extension module for AES, `_AES`, fails to compile or is not correctly linked during the `pycrypto` installation, leading to an incomplete or broken installation.
fix
This issue indicates a problem with the PyCrypto installation. The most reliable solution is to uninstall PyCrypto and install PyCryptodome (`pip install pycryptodome`), which is a drop-in replacement and generally more stable.
AttributeError: module 'Crypto.Cipher.AES' has no attribute 'MODE_GCM'
This typically means an older version of PyCrypto is installed that lacks support for specific advanced modes like GCM, or there's an API mismatch with how modes are accessed, especially when transitioning or mixing with PyCryptodome. Another common related error is `AES.new(key)` failing because symmetric ciphers in PyCryptodome no longer default to ECB mode.
fix
Upgrade to `pycryptodome` which offers broader algorithm support and explicitly specify the cipher mode when creating an AES object (e.g., `from Crypto.Cipher import AES; cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)`). If using `AES.new(key)`, specify `AES.MODE_ECB` if that's the desired (but insecure) mode: `AES.new(key, AES.MODE_ECB)`.
Upgrade
Version history
2.6.1latest on PyPI · released Jun 20, 2014
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
1
Resources
pycrypto — pip install pycrypto · libregistry