pqr
Post-quantum resistant encryption from your terminal.
pqr is a single Rust binary. It takes about 4.5 MB on disk and under 5 MB of memory to encrypt a message (numbers from a release build on an Apple Silicon Mac; see Size and speed). It also comes as a TypeScript package for Bun and Node, for people who want to install it with their JS tooling or call it from code. See src/src_ts/README.md.
It works on macOS, Linux, and Windows (native or WSL).
pqr makes a key, encrypts text with it, and decrypts it again. There are no algorithms to pick and no keyrings to manage. Under the hood it's standard OpenPGP with the new post-quantum algorithms, so a message you encrypt today stays private even if someone records it and waits for a quantum computer.
[!NOTE] pqr is new, and its commands may still change.
Install
With Rust:
No Rust yet? This installs it first with rustup, the official installer, and skips that step if cargo is already there:
|| { | && ; }
With Bun (1.2 or newer):
With Node (22.18 or newer):
Pick one. Neither needs Rust: on first run, pqr downloads a prebuilt binary for your machine.
There's nothing else to install. The post-quantum crypto is built into the pqr binary itself, so it doesn't depend on OpenSSL or on your Node or Bun version.
Build it yourself (if you'd rather not run a prebuilt binary):
&&
The Bun and Node package uses a pqr it finds on your PATH before it ever downloads one,
so installing it this way first means nothing gets downloaded. You can also point it at a
specific binary with PQR_BIN=/path/to/pqr. Each prebuilt release also ships a .sha256 file,
and the package refuses any download that doesn't match it.
Quick start
pqr keygen saves two files: main.key (your secret key, keep it private) and main.pub
(the public half, fine to share). It also prints the public half so you can copy it.
That's it. Only your key can open msg.pgp.
More examples
| | |
Writing a script? pqr -e does the same thing as plain pqr, so you can build the command
as pqr -e ... or pqr -d .... You can't use both flags at once.
Keep secrets out of your shell history
Anything you type after pqr shows up in your shell history and in ps while it runs.
For real secrets, pipe them in or use a file:
Send a secret to a server
Say you want to get a .env file onto a server without it ever sitting around in plain text.
Make a key on the server, bring its public half home, and encrypt with that:
# 1. Install pqr on the server and make its key. The public key lands on your laptop as server.pub
# 2. On your laptop, encrypt for the server
# 3. Send it over and decrypt it there
&&
The server's secret key never leaves the server, so env.pgp is safe to keep in git or paste into a chat.
Whoever has the secret key (.key) can decrypt. Whoever has the public key (.pub) can only encrypt.
Both machines need pqr installed.
If the server says pqr: command not found, its non-interactive shell didn't load your profile.
Use ~/.cargo/bin/pqr in those commands instead. If the server doesn't have Rust, run the two
Install lines there first.
Back up a server so only your laptop can read it
This is the same idea in reverse. The server encrypts with your laptop's public key:
If someone steals the server or its backup disk, all they get is ciphertext.
What about SSH itself?
pqr protects the files. SSH protects the connection. Since OpenSSH 10, SSH uses a post-quantum
key exchange (mlkem768x25519-sha256) by default
(release notes), but not every build puts it first.
Check yours:
|
If the list doesn't start with mlkem768x25519-sha256, add this to the top of ~/.ssh/config:
Host *
KexAlgorithms ^mlkem768x25519-sha256,sntrup761x25519-sha512
The ^ moves those two to the front and keeps everything else as a fallback, so older servers still connect.
Use it from TypeScript
The same package works as a library on Node or Bun. It has no dependencies, and plaintext goes to pqr through stdin.
import { keygen, encrypt, decryptText } from "@prith-pal/pqr";
await keygen(); // your key, saved in ~/.config/pqr/keys/
const note = await encrypt("API_TOKEN=yoda"); // only your key can open it
console.log(await decryptText(note)); // API_TOKEN=yoda
// Or encrypt for a server, using the path to its public key file
const forServer = await encrypt("API_TOKEN=yoda", { recipient: "./keys/server.pub" });
const fromEnv = await encrypt("API_TOKEN=yoda", { recipient: process.env.SERVER_PUB }); // or the key text itself, e.g. from an env var
See src/src_ts/README.md for the full API.
Size and speed
Measured on an Apple M4 Max with macOS 26.7.2 and Rust 1.92, using a release build. Each operation ran 5 times; the table shows the median.
| Operation | Peak memory | Time |
|---|---|---|
| Binary size on disk | 4.5 MB | n/a |
pqr keygen |
4.6 MB | under 0.01 s |
| Encrypt a short message | 4.1 MB | under 0.01 s |
| Decrypt that message | 4.6 MB | under 0.01 s |
| Encrypt a 10 MB file | 40.0 MB | 0.19 s |
| Decrypt that 10 MB file | 30.5 MB | 0.19 s |
Decrypt holds the whole message in memory before it prints anything, so memory grows with file size. This is deliberate: a tampered message never prints partial plaintext.
To reproduce, build with cargo build --release, point PQR_DIR at a scratch folder, and wrap each command in /usr/bin/time -l (macOS reports "maximum resident set size" in bytes):
Reference
| Command | What it does |
|---|---|
pqr keygen |
Makes your key. It won't overwrite one that already exists. |
pqr TEXT or pqr -e TEXT |
Encrypts TEXT (or stdin) with your key. |
pqr -r KEY TEXT |
Encrypts for someone else. KEY is a public key file, or the key text itself. |
pqr -d FILE |
Decrypts a file, a pasted message, or stdin. |
-i NAME |
Uses a different key than main, for keygen, encrypt, or -d. |
Your keys live in ~/.config/pqr/keys (or $XDG_CONFIG_HOME/pqr/keys, or $PQR_DIR/keys if you set it).
Each key is a pair of files: main.key (secret, readable only by you) and main.pub (fine to share).
When decryption fails, pqr prints nothing and exits with a code that tells you why:
| Code | Meaning |
|---|---|
| 0 | Worked |
| 1 | Bad arguments, or a file couldn't be read |
| 2 | This message wasn't encrypted for your key |
| 3 | The message was changed or cut off |
Under the hood
pqr uses one fixed setup and doesn't let you change it:
- OpenPGP v6 keys (RFC 9580)
- ML-KEM-768 + X25519 for encryption and ML-DSA-65 + Ed25519 for signing (RFC 9980)
- Messages are encrypted and authenticated together (SEIPD v2)
Each algorithm is paired with a classical one, so a break in either still leaves the other. pqr refuses public keys that don't have a post-quantum part, because encrypting for one would undo the point.
The crypto comes from rPGP with its pqc feature.
rPGP has been audited, but its post-quantum code is newer than those audits.
[!WARNING] Your secret key isn't password-protected yet. Only its file permissions keep other users out. Passphrase support is next.
Development
The Rust CLI lives in src/src_rust, and the TypeScript package lives in src/src_ts. These are the same checks CI runs:
&& &&
cargo build --release makes the small, stripped binary in target/release/pqr.
This repo is built with AI coding agents. AGENTS.md has the rules they follow, and CONTRIBUTING.md covers commits and pull requests.
License
Licensed under either of Apache License 2.0 or MIT, at your option.