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
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)
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]
pip install sslcrypto[all]

Generate an AES key, IV, encrypt and decrypt a message using CBC mode.

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)