๐Ÿ“ฆ woodruffw / pyrage

Python bindings for rage (age in Rust)

โ˜… 79 stars โ‘‚ 8 forks ๐Ÿ‘ 79 watching โš–๏ธ MIT License
ageencryption-decryptionpythonrustsshx25519
๐Ÿ“ฅ Clone https://github.com/woodruffw/pyrage.git
HTTPS git clone https://github.com/woodruffw/pyrage.git
SSH git clone git@github.com:woodruffw/pyrage.git
CLI gh repo clone woodruffw/pyrage
dependabot[bot] dependabot[bot] build(deps): bump the actions group with 2 updates (#133) c7e850c 1 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ pyrage-stubs
๐Ÿ“ src
๐Ÿ“ test
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.lock
๐Ÿ“„ Cargo.toml
๐Ÿ“„ LICENSE
๐Ÿ“„ Makefile
๐Ÿ“„ pyproject.toml
๐Ÿ“„ README.md
๐Ÿ“„ README.md

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

$ source env/bin/activate
$ make develop

Licensing

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