
age v1.3.2
一个简单、现代且安全的加密工具(及 Go 库),具有简短明确的密钥、无配置选项,以及 UNIX 风格的可组合性。
age 是一款简单、现代且安全的文件加密工具、格式和 Go 库。
它具备小巧明确的密钥、后量子支持、无配置选项以及 UNIX 风格的可组合性。
$ age-keygen -o key.txt
Public key: age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
$ tar cvz ~/data | age -r age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p > data.tar.gz.age
$ age --decrypt -i key.txt data.tar.gz.age > data.tar.gz
📜 格式规范位于 age-encryption.org/v1。age 由 @benjojo 和 @FiloSottile 设计。
🦀 另一个可互操作的 Rust 实现位于 github.com/str4d/rage。
🌍 Typage 是一个 TypeScript 实现。它可在浏览器、Node.js、Deno 和 Bun 中运行。
🔑 通过 age-plugin-yubikey 插件支持 YubiKey 等硬件 PIV 令牌。
✨ 更多插件、实现、工具和集成,请查看 awesome age 列表。
💬 作者将其发音为 [aɡe̞],带有硬音 g,类似 GIF,并且始终以小写拼写。
安装
| Homebrew(macOS 或 Linux) |
brew install age
|
| MacPorts |
port install age
|
| Windows |
winget install --id FiloSottile.age
|
| Alpine Linux v3.15+ |
apk add age
|
| Arch Linux |
pacman -S age
|
| Debian 12+(Bookworm) |
apt install age
|
| Debian 11(Bullseye) |
apt install age/bullseye-backports
(启用 backports 以获取 age v1.0.0+)
|
| Fedora 33+ |
dnf install age
|
| Gentoo Linux |
emerge app-crypt/age
|
| Guix System |
guix package -i age
|
| NixOS / Nix |
nix-env -i age
|
| openSUSE Tumbleweed |
zypper install age
|
| Ubuntu 22.04+ |
apt install age
|
| Void Linux |
xbps-install age
|
| FreeBSD |
pkg install age(security/age)
|
| OpenBSD 6.7+ |
pkg_add age(security/age)
|
| Chocolatey(Windows) |
choco install age.portable
|
| Scoop(Windows) |
scoop bucket add extras && scoop install age
|
在 Windows、Linux、macOS 和 FreeBSD 上,您可以使用预编译二进制文件。
- https://dl.filippo.io/age/latest?for=linux/amd64
- https://dl.filippo.io/age/v1.3.2?for=darwin/arm64
- ...
如果您下载了预编译二进制文件,可以验证其 Sigsum 证明。
如果您的系统具有受支持的 Go 版本,则可以从源代码构建。
go install filippo.io/age/cmd/...@latest
非常欢迎新的打包者提供帮助。
用法
完整文档请阅读 age(1) 手册页。
Usage:
age [--encrypt] (-r RECIPIENT | -R PATH)... [--armor] [-o OUTPUT] [INPUT]
age [--encrypt] --passphrase [--armor] [-o OUTPUT] [INPUT]
age --decrypt [-i PATH]... [-o OUTPUT] [INPUT]
Options:
-e, --encrypt Encrypt the input to the output. Default if omitted.
-d, --decrypt Decrypt the input to the output.
-o, --output OUTPUT Write the result to the file at path OUTPUT.
-a, --armor Encrypt to a PEM encoded format.
-p, --passphrase Encrypt with a passphrase.
-r, --recipient RECIPIENT Encrypt to the specified RECIPIENT. Can be repeated.
-R, --recipients-file PATH Encrypt to recipients listed at PATH. Can be repeated.
-i, --identity PATH Use the identity file at PATH. Can be repeated.
--version Print the version.
INPUT defaults to standard input, and OUTPUT defaults to standard output.
If OUTPUT exists, it will be overwritten.
RECIPIENT can be an age public key generated by age-keygen ("age1...")
or an SSH public key ("ssh-ed25519 AAAA...", "ssh-rsa AAAA...").
Recipient files contain one or more recipients, one per line. Empty lines
and lines starting with "#" are ignored as comments. "-" may be used to
read recipients from standard input.
Identity files contain one or more secret keys ("AGE-SECRET-KEY-1..."),
one per line, or an SSH key. Empty lines and lines starting with "#" are
ignored as comments. Passphrase encrypted age files can be used as
identity files. Multiple key files can be provided, and any unused ones
will be ignored. "-" may be used to read identities from standard input.
When --encrypt is specified explicitly, -i can also be used to encrypt to an
identity file symmetrically, instead or in addition to normal recipients.
多个接收者
可以通过重复 -r/--recipient 将文件加密给多个接收者。每个接收者都能解密该文件。
$ age -o example.jpg.age -r age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p \
-r age1lggyhqrw2nlhcxprm67z43rta597azn8gknawjehu9d9dl0jq3yqqvfafg example.jpg
接收者文件
多个接收者也可以逐行列在一个或多个通过 -R/--recipients-file 标志传递的文件中。
$ cat recipients.txt
# Alice
age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p
# Bob
age1lggyhqrw2nlhcxprm67z43rta597azn8gknawjehu9d9dl0jq3yqqvfafg
$ age -R recipients.txt example.jpg > example.jpg.age
如果 -R(或 -i)的参数是 -,则从标准输入读取文件。
后量子密钥
要生成混合后量子密钥(可抵御未来量子计算机攻击),请在 age-keygen 中使用 -pq 标志。这可能在将来成为默认选项。
后量子身份以 AGE-SECRET-KEY-PQ-1... 开头,接收者以 age1pq1... 开头。遗憾的是,接收者长度约为 2000 个字符。
$ age-keygen -pq -o key.txt
$ age-keygen -y key.txt > recipient.txt
$ age -R recipient.txt example.jpg > example.jpg.age
$ age -d -i key.txt example.jpg.age > example.jpg
后量子密钥支持已内置于 age v1.3.0 及更高版本。或者,可以安装 age-plugin-pq 二进制文件并将其放入 $PATH,以便为任何支持插件的 age 版本和实现添加支持。接收者开箱即用,而身份则需要使用 age-plugin-pq -identity 转换为插件身份。
口令
可以使用 -p/--passphrase 通过口令加密文件。默认情况下,age 会自动生成一个安全的口令。受口令保护的文件在解密时会自动检测。