Skip to content

Instantly share code, notes, and snippets.

@snandam
Last active April 7, 2026 17:51
Show Gist options
  • Select an option

  • Save snandam/4b0d52f8a7936ace3f53e13f25a07395 to your computer and use it in GitHub Desktop.

Select an option

Save snandam/4b0d52f8a7936ace3f53e13f25a07395 to your computer and use it in GitHub Desktop.
Sharing Secrets using Age

Secret sharing using age

age is a simple, modern file encryption tool for sharing secrets via public-key encryption.

Install

macOS

brew install age

Windows

scoop install age

Verify:

age --version

Create a new key

  • When someone wants to share a secret, generate a key pair and send them your public key.
  • Create separate keys per context.
age-keygen -o age-key.txt
  • age-key.txt contains your private key — never share it.
  • The public key is printed to your terminal. Share only that line:
Public key: age1dnnrsy2yeevh7tpk007rkzj9kruk4j9kt3z3ywnqvynhzamvcuwql27jzm

Encrypt contents

  • Get the recipient's public key.
  • Put secrets in secret.txt, then encrypt:
age -o secret.txt.age -r age1dnnrsy2yeevh7tpk007rkzj9kruk4j9kt3z3ywnqvynhzamvcuwql27jzm secret.txt

Decrypt contents

  • You have a .age file someone encrypted with your public key.
  • Decrypt it with your private key:
age --decrypt -i age-key.txt ~/Downloads/secret.txt.age > ~/Downloads/secret.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment