py3rijndael
raw JSON → 0.3.3 verified Mon Apr 27 auth: no python maintenance
Rijndael (AES) encryption algorithm library for Python 3. Current version 0.3.3, last updated in 2020, maintenance mode.
pip install py3rijndael Common errors
error ImportError: No module named 'rijndael' ↓
cause Incorrect import path; the pip package name is py3rijndael.
fix
Run 'pip install py3rijndael' and import as 'from py3rijndael import Rijndael'.
error AttributeError: module 'py3rijndael' has no attribute 'ZeroPadding' ↓
cause ZeroPadding is not imported correctly from the top-level module.
fix
Use 'from py3rijndael.zero_padding import ZeroPadding'.
error ValueError: encrypted data must be padded to block boundary ↓
cause The padding block size in ZeroPadding does not match the cipher block size or input length.
fix
Use the same block_size for padding as the Rijndael block_size (or multiple) and ensure plaintext length is a multiple of padding block size.
Warnings
breaking Block size for Rijndael is not limited to 16 bytes (128 bits); using non-standard block sizes may lead to interoperability issues. ↓
fix Use block_size=16 for AES compatibility.
deprecated This library is in maintenance mode with no updates since 2020. Consider using 'pycryptodome' or 'cryptography' for active support. ↓
fix Migrate to pycryptodome or cryptography packages.
gotcha The padding must be compatible with the block size. ZeroPadding(32) pads to 32-byte blocks, but the cipher block_size is separate. Mismatch causes silent corruption. ↓
fix Ensure padding block size is a multiple of the cipher block size (e.g., 16 is recommended).
gotcha Rijndael supports key sizes of 16, 24, 32 bytes, but this library also allows other sizes? Use standard sizes to avoid unexpected behavior. ↓
fix Use key length of 16, 24, or 32 bytes.
Imports
- Rijndael wrong
from rijndael import rijndaelcorrectfrom py3rijndael import Rijndael - ZeroPadding wrong
from py3rijndael import ZeroPaddingcorrectfrom py3rijndael.zero_padding import ZeroPadding
Quickstart
from py3rijndael import Rijndael
from py3rijndael.zero_padding import ZeroPadding
import os
key = b'0123456789abcdef' # 16 bytes for AES-128
iv = os.urandom(16)
plaintext = b'Hello World!'
rijndael = Rijndael(key, block_size=16, iv=iv, padding=ZeroPadding(32))
encrypted = rijndael.encrypt(plaintext)
decrypted = rijndael.decrypt(encrypted)
print(decrypted.decode())