Write, share, and carry your context everywhere. Create your free account today.

06 mdflow-crypt CLI

Raw

mdflow-crypt CLI

mdflow-crypt encrypts and decrypts MDflow documents locally, from the command line.

It is a standalone, zero-dependency CLI you run on your own machine. Your plaintext and your password never leave your computer — they never reach a server, and never reach an AI model.

Works on Node 18 or later. It does not need a Personal Access Token, and it is not Pro-gated — it operates on files, not on your account.

Why it exists

MDflow encrypts a document's body in your browser (see 01 Document Encryption), and the server only ever stores ciphertext (mdflow-enc:v1:…). That is a strong guarantee, but it has an awkward consequence: an encrypted document you exported is unreadable outside a browser that has the key.

This tool does the same crypto on your own machine, so you can take an encrypted document out of MDflow and read or write it offline.

Usage

# decrypt: an mdflow-enc:v1 file → <name>_decrypted.md
npx mdflow-crypt decrypt notes.md

# encrypt: a markdown file → <name>_encrypted.md  (paste the result into MDflow)
npx mdflow-crypt encrypt notes.md

Install it permanently instead of using npx:

npm install -g mdflow-crypt
mdflow-crypt encrypt notes.md

The output is written next to the input, with the original extension dropped:

Commandreport.md becomes
encryptreport_encrypted.md
decryptreport_decrypted.md

Passwords

The password is resolved in this order — first match wins:

  1. --password <pw> — an inline flag
  2. --password-file <path> — read from a file (the first line)
  3. the [password] positional argument
  4. otherwise you are prompted, hidden (encrypt asks twice to confirm)

--password and the positional argument are visible to other processes and land in your shell history. For anything sensitive, use the hidden prompt, or a --password-file with chmod 600.

# password from a file instead of the prompt
npx mdflow-crypt encrypt notes.md --password-file ~/.secrets/notes.pw

Interoperability

The format is mdflow-enc:v1 — PBKDF2 at 600,000 iterations, then AES-256-GCM. It is the same format everywhere:

Encrypt here, paste the ciphertext into MDflow, and it opens with the same password. Export an encrypted document from MDflow and decrypt it here. There is no lock-in, even for encrypted content.

A warning about AI agents

This one matters:

Do not ask an AI agent to decrypt your documents. The moment an agent runs mdflow-crypt decrypt, the plaintext is in its context — which is precisely the thing you encrypted the document to prevent.

mdflow-crypt is meant to be run by a human. The whole point of encrypting a document is that your agents cannot read it; handing an agent the password and the CLI dissolves that guarantee completely, and more quietly than you would like.

If you want an agent to work with the content, do not encrypt it. If you encrypted it, decrypt it yourself.

Typical uses

  • Read an exported encrypted document offline. A workspace export (see 02 Exporting a Workspace) contains encrypted documents as ciphertext — this is how you read them.
  • Recover content after cancelling Pro, or after leaving MDflow entirely.
  • Prepare an encrypted document offline and paste the ciphertext in.
  • Keep encrypted markdown in a git repository, where only you can read it.

If you lose the password

Nothing can be done. Not by this tool, not by MDflow, not by anyone. The key is derived from your password and exists nowhere else.