woodruffw/pyrage

Python bindings for rage (age in Rust)

Rust

91

215 commits

updated Sep 21, 2026

See the code

README

pyrage

CI PyPI version PyPI Downloads

Python bindings for the Rust implementation of age.

Index

Installation

You can install pyrage with pip:

$ python -m pip install pyrage

PEP 561-style type stubs are also available:

$ python -m pip install pyrage-stubs

See the development instructions below for manual installations.

Usage

Identity generation (x25519 only)

from pyrage import x25519

ident = x25519.Identity.generate()

# returns the public key
ident.to_public()

# returns the private key
str(ident)

Identity-based encryption and decryption

from pyrage import encrypt, decrypt, ssh, x25519

# load some identities
alice = x25519.Identity.from_str("AGE-SECRET-KEY-...")
bob = ssh.Identity.from_buffer(b"---BEGIN OPENSSH PRIVATE KEY----...")

# load some recipients
carol = x25519.Recipient.from_str("age1z...")
dave = ssh.Recipient.from_str("ssh-ed25519 ...")

# encryption
encrypted = encrypt(b"bob can't be trusted", [carol, dave, alice.to_public()])

# decryption
decrypted = decrypt(encrypted, [alice, bob])

Passphrase encryption and decryption

from pyrage import passphrase

encrypted = passphrase.encrypt(b"something secret", "my extremely secure password")
decrypted = passphrase.decrypt(encrypted, "my extremely secure password")

Development

$ uv sync --locked
$ uv run --locked python -m unittest

Licensing

pyrage is released and distributed under the terms of the MIT License.

age
encryption-decryption
python
rust
ssh
x25519

Contributors

woodruffw

105 commits

dependabot[bot]

94 commits

magnuswatn

4 commits

Alchemyst0x

2 commits

Languages

Rust

63.0%

Python

35.8%

Makefile

1.2%

woodruffw/pyrage

Python bindings for rage (age in Rust)

Rust

91

215 commits

updated Sep 21, 2026

See the code

README

pyrage

CI PyPI version PyPI Downloads

Python bindings for the Rust implementation of age.

Index

Installation

You can install pyrage with pip:

$ python -m pip install pyrage

PEP 561-style type stubs are also available:

$ python -m pip install pyrage-stubs

See the development instructions below for manual installations.

Usage

Identity generation (x25519 only)

from pyrage import x25519

ident = x25519.Identity.generate()

# returns the public key
ident.to_public()

# returns the private key
str(ident)

Identity-based encryption and decryption

from pyrage import encrypt, decrypt, ssh, x25519

# load some identities
alice = x25519.Identity.from_str("AGE-SECRET-KEY-...")
bob = ssh.Identity.from_buffer(b"---BEGIN OPENSSH PRIVATE KEY----...")

# load some recipients
carol = x25519.Recipient.from_str("age1z...")
dave = ssh.Recipient.from_str("ssh-ed25519 ...")

# encryption
encrypted = encrypt(b"bob can't be trusted", [carol, dave, alice.to_public()])

# decryption
decrypted = decrypt(encrypted, [alice, bob])

Passphrase encryption and decryption

from pyrage import passphrase

encrypted = passphrase.encrypt(b"something secret", "my extremely secure password")
decrypted = passphrase.decrypt(encrypted, "my extremely secure password")

Development

$ uv sync --locked
$ uv run --locked python -m unittest

Licensing

pyrage is released and distributed under the terms of the MIT License.

age
encryption-decryption
python
rust
ssh
x25519

Contributors

woodruffw

105 commits

dependabot[bot]

94 commits

magnuswatn

4 commits

Alchemyst0x

2 commits

Languages

Rust

63.0%

Python

35.8%

Makefile

1.2%