pyrage
raw JSON → 1.3.0 verified Sat May 09 auth: no python
Python bindings for rage (age in Rust). Provides encryption/decryption using age keys. Version 1.3.0, active development, monthly/bimonthly releases.
pip install pyrage Common errors
error ModuleNotFoundError: No module named 'pyrage' ↓
cause pyrage not installed or installed in wrong environment.
fix
Run
pip install pyrage. Ensure you're in the correct virtual environment. error AttributeError: module 'pyrage' has no attribute 'encrypt' ↓
cause Wrong import path. `encrypt` is a top-level function, not under a submodule.
fix
Use
from pyrage import encrypt or import pyrage; pyrage.encrypt(...) Warnings
gotcha The `encrypt` and `decrypt` functions expect bytes, not strings. Provide bytes-like objects. ↓
fix Encode strings with `.encode()` before encrypting; decode with `.decode()` after decrypting.
deprecated Python 3.8 support dropped in v1.2.2. Requires Python >=3.9. ↓
fix Upgrade to Python 3.9+.
Imports
- generate
from pyrage import x25519
Quickstart
from pyrage import x25519
from pyrage import encrypt, decrypt
# Generate a key
keys = x25519.Identity.generate()
print("Identity (secret):", str(keys))
print("Recipient (public):", str(keys.to_public()))
# Encrypt a message
plaintext = b"Hello, age!"
recipients = [keys.to_public()]
encrypted = encrypt(plaintext, recipients)
print("Encrypted:", encrypted)
# Decrypt
identities = [keys]
decrypted = decrypt(encrypted, identities)
print("Decrypted:", decrypted)