sslcrypto
raw JSON → 5.3 verified Fri May 01 auth: no python
sslcrypto is a Python library providing ECIES (Elliptic Curve Integrated Encryption Scheme), AES, and RSA encryption with OpenSSL-based implementation and a pure Python fallback. Current version 5.3 offers multiple backends (OpenSSL, LibreSSL, cryptography, pure Python) and supports a wide range of curves and RSA key sizes. Release cadence is irregular, with occasional major version bumps due to API changes.
pip install sslcrypto Common errors
error ModuleNotFoundError: No module named 'sslcrypto' ↓
cause sslcrypto is not installed.
fix
Run
pip install sslcrypto error sslcrypto.lib.backend.UnavailableBackendError: Cannot find any suitable backend ↓
cause No OpenSSL, LibreSSL, or cryptography library found. Pure Python fallback not available because optional dependencies are missing.
fix
Install sslcrypto with 'all' extra:
pip install sslcrypto[all] error TypeError: initial_value must be bytes or None ↓
cause Passed a non-bytes value (e.g., string) to AES initialization (iv argument).
fix
Ensure iv is bytes:
iv = b'some_16_byte_iv' or iv = os.urandom(16) Warnings
breaking Version 4.x to 5.x broke named curve arguments: use curve name as string directly, not as key in a dict. Previous usage `curve='secp256k1'` still works, but internal API changed. ↓
fix Update to new pattern if you were passing curve as keyword to low-level functions; generally safe if using high-level wrappers.
breaking AES encryption in version 5 returns bytes object in Python 3, not base64 string as in older versions. Decryption expects raw bytes. ↓
fix Encode/decode to base64 manually if needed: base64.b64encode(encrypted)
deprecated The `ciphertext` attribute of AES objects is deprecated; use `cipher.encrypt()` return value directly. ↓
fix Use cipher.encrypt(data) instead of cipher.ciphertext
gotcha Default backend selection may fail on systems without OpenSSL. Install with `[all]` extra to ensure fallback works. ↓
fix pip install sslcrypto[all]
Install
pip install sslcrypto[all] Imports
- aes wrong
from sslcrypto import AEScorrectfrom sslcrypto import aes - ecc wrong
from sslcrypto.ecc import ECCcorrectfrom sslcrypto import ecc - rsa wrong
from sslcrypto.rsa import RSAcorrectfrom sslcrypto import rsa
Quickstart
from sslcrypto import aes
key = aes.generate_key()
iv = aes.generate_iv()
cipher = aes.new(key, aes.MODE_CBC, iv=iv)
encrypted = cipher.encrypt(b'secret message')
decipher = aes.new(key, aes.MODE_CBC, iv=iv)
decrypted = decipher.decrypt(encrypted)
print(decrypted)