---
title: "CLI"
description: "The ciphers command and its subcommands. Then the flags each cipher reads."
canonical_url: "https://ciphers.agntn.dev/guide/cli"
---
# CLI

> The ciphers command and its subcommands. Then the flags each cipher reads.

## Run it

```bash
pnpm add -g @agntn/ciphers
ciphers caesar "ATTACK AT DAWN" --shift 3
# DWWDFN DW GDZQ
```

First word not a command? Then it's a cipher name and the CLI encodes. `ciphers caesar ...` and `ciphers encode caesar ...` are the same call, because typing `encode` every time gets old fast. No words at all lists the ciphers.

Every command is one of the agent tools. `runCli` from [`@agntn/tools`](https://tools.agntn.dev/guide/cli) builds them from the same schemas MCP, Pi and OMP read. So a flag the schema refuses gets refused here too. Same rule, your spelling: the line names `--max-period` where a model would see `/maxPeriod`. No second parser to drift away from the first one.

<table>
<thead>
  <tr>
    <th>
      Command
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        ciphers encode <cipher> <text>
      </code>
    </td>
    
    <td>
      Encode with a cipher
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers decode <cipher> <text>
      </code>
    </td>
    
    <td>
      Decode with a cipher
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers brute <text>
      </code>
    </td>
    
    <td>
      All 25 Caesar shifts, best <code>
        --lang
      </code>
      
       fit first (<code>
        en
      </code>
      
      , <code>
        pl
      </code>
      
      , <code>
        ja
      </code>
      
      )
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers frequency <text>
      </code>
    </td>
    
    <td>
      Letter histogram and index of coincidence
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers period <text>
      </code>
    </td>
    
    <td>
      Vigenère key lengths by column IoC and Kasiski, the likely key for the top three
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers guess <text>
      </code>
    </td>
    
    <td>
      Likely cipher families, each with its signal and the call to try next
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers probe <text> --key <passphrase>
      </code>
    </td>
    
    <td>
      Padding hits of a <code>
        Salted__
      </code>
      
       blob across digests, key lengths and iterations, next to the count chance gives
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers crib '["<hex>","<hex>"]' --crib <text>
      </code>
    </td>
    
    <td>
      Slide a crib across ciphertexts under one reused XOR key, most readable places first
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers hidden <text>
      </code>
    </td>
    
    <td>
      A message hidden by position, the likeliest readings first, or one place with <code>
        --pick
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers inspect <text>
      </code>
    </td>
    
    <td>
      Find invisible and lookalike characters, with <code>
        --script
      </code>
      
       to set the expected script
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers reveal <text>
      </code>
    </td>
    
    <td>
      Read messages in invisible characters, with <code>
        --scheme
      </code>
      
       to select one
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers conceal <text>
      </code>
    </td>
    
    <td>
      Hide a message in invisible characters, with <code>
        --cover
      </code>
      
       for surrounding text
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers whitespace <text>
      </code>
    </td>
    
    <td>
      List whitespace positions, or read bits with <code>
        --channel
      </code>
      
      , <code>
        --zero
      </code>
      
       and <code>
        --one
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers trail <text> --cover <cover> --zero <class> --one <class>
      </code>
    </td>
    
    <td>
      Hide a message at line ends, with <code>
        --per-line
      </code>
      
       to set the number of bits per line
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers align <left> <right>
      </code>
    </td>
    
    <td>
      Compare two texts word by word, or check edited rows with <code>
        --rows
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers recover <text> --cipher <cipher>
      </code>
    </td>
    
    <td>
      Search the key of a Vigenère, Beaufort, variant Beaufort, substitution, columnar or homophonic text, best first
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers info [cipher]
      </code>
    </td>
    
    <td>
      Every cipher by category, or one cipher's family, options and keyspace. <code>
        --category classical
      </code>
      
       keeps one category
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers ciphers
      </code>
    </td>
    
    <td>
      Same as <code>
        info
      </code>
      
      , the old name still works
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        ciphers mcp
      </code>
    </td>
    
    <td>
      Run the MCP server over stdio
    </td>
  </tr>
</tbody>
</table>

## Examples

```bash
ciphers encode caesar "ATTACK AT DAWN" --shift 3     # DWWDFN DW GDZQ
ciphers decode atbash "ZGGZXP ZG WZDM"                # ATTACK AT DAWN
ciphers encode vigenere "ATTACK AT DAWN" --key LEMON  # LXFOPV EF RNHR
ciphers encode alberti "ATTACK AT DAWN" --key ALBERTI --period 4
ciphers encode affine "AFFINE CIPHER" --a 5 --b 8     # IHHWVC SWFRCP
ciphers encode rail-fence "WEAREDISCOVEREDRUNATONCE" --rails 3
ciphers encode playfair "HIDE THE GOLD" --key "PLAYFAIR EXAMPLE"
ciphers encode columnar "ATTACK AT DAWN" --key ZEBRA
ciphers encode bifid "FLEE AT ONCE" --key BICONDITIONAL --period 5
ciphers encode enigma "ATTACK AT DAWN" --positions MCK --rings BDF --plugboard "AV BS CG"
ciphers encode morse "SOS"                             # ... --- ...
ciphers encode tap-code "HELP"                         # 2 3 1 5 3 1 3 5
ciphers brute "KHOOR"                                  # shift= 3 -> HELLO
ciphers frequency "DWWDFN DW GDZQ" --lang en
ciphers hidden - --pick line < poem.txt                # the first letter of every line
ciphers inspect - < tweet.txt                          # what's in there that you can't see
ciphers reveal - < note.txt                            # and what it spells
ciphers whitespace - < note.txt                        # where the spaces and tabs sit
ciphers align "red fox sleeps" "red fox runs"          # which word changed
ciphers info enigma
```

## Dashes and stdin

Morse starts with a dash half the time. Every armored PGP message starts with five. Neither spells a flag, so the parser reads it as the text. `-.-.` stays a C. Once the text is in, a dashed word is an unknown option again. A typo after it fails instead of sneaking into your message. `--` and a piped `-` still work too:

```bash
ciphers decode morse '-.-. .- -'                      # CAT
ciphers decode morse -- '-.-. .- -'                   # CAT
echo '-.-. .- -' | ciphers decode morse -             # CAT
ciphers decode openpgp - --key causality < message.asc
ciphers decode morse '...' --kye x                     # Invalid arguments: unknown option "--kye"; takes --shift, ...
```

`-` works for the text of every command but `crib`. On `encode` and `decode` it also works for `--book`. Stdin feeds one argument per call and has to be valid UTF-8. Anything else is refused, not quietly mangled.

## Flags

`encode` and `decode` read the same flags. A flag the cipher doesn't use is ignored, no complaint. Long names only: there's no `-k` for `--key`.

<table>
<thead>
  <tr>
    <th>
      Flag
    </th>
    
    <th>
      Ciphers
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        --shift <n>
      </code>
    </td>
    
    <td>
      caesar
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --key <word>
      </code>
    </td>
    
    <td>
      vigenere, gronsfeld (digits only), beaufort, porta, autokey, running-key (a passage, a letter per letter of the text), alberti, quagmire-1 to quagmire-4, chaocipher (the left, ciphertext alphabet), playfair, four-square, two-square, hill, polybius, nihilist, fractionated-morse (the alphabet over the triples), columnar, adfgvx, bifid, trifid (a keyword for the cube), straddling-checkerboard (the board, 28 cells), tridigital (a 10-letter keyword or the digits 0 to 9) and every <code>
        block
      </code>
      
       and <code>
        stream
      </code>
      
       cipher (hex, but the password itself for aes-passphrase, openpgp and zipcrypto)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --second-key <word>
      </code>
    </td>
    
    <td>
      four-square, the keyword for its bottom left square, two-square, for its bottom or right one, quagmire-4, for its cipher alphabet, chaocipher, for its right, plaintext alphabet, and tridigital, for the alphabet in its block
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --indicator <word>
      </code>
    </td>
    
    <td>
      quagmire-1 to quagmire-4, the keyword that picks the cipher row for each letter
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --indicator-under <letter>
      </code>
    </td>
    
    <td>
      quagmire-1 to quagmire-4, the plain letter the indicator stands under, <code>
        A
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --transposition <word>
      </code>
    </td>
    
    <td>
      adfgvx
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --square <word>
      </code>
    </td>
    
    <td>
      nihilist, the keyword for its square
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --rotation <left|right>
      </code>
    </td>
    
    <td>
      porta, <code>
        right
      </code>
      
       for the dCode table
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --omit <j|q>
      </code>
    </td>
    
    <td>
      four-square and two-square, <code>
        q
      </code>
      
       for squares without Q as on Wikipedia
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --orientation <vertical|horizontal>
      </code>
    </td>
    
    <td>
      two-square, <code>
        horizontal
      </code>
      
       for squares side by side as the ACA and dCode set them
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --blanks <digits>
      </code>
    </td>
    
    <td>
      straddling-checkerboard
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --symbol <char>
      </code>
    </td>
    
    <td>
      trifid, the 27th cell of its cube, <code>
        +
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --alphabet <symbols>
      </code>
    </td>
    
    <td>
      hill, the symbols in order with the first as 0, A-Z by default, so <code>
        012345678
      </code>
      
       works mod 9. polybius and bifid, a square number of distinct symbols, filling the square row by row after the keyword, so 36 make a 6×6
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --separator <text>
      </code>
    </td>
    
    <td>
      a1z26, <code>
        -
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --zero <letter>
      </code>
    </td>
    
    <td>
      a1z26, the single digit form
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --book <text>
      </code>
    </td>
    
    <td>
      book, the whole text to count in, or <code>
        -
      </code>
      
       to read it from stdin
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --address <form>
      </code>
    </td>
    
    <td>
      book, <code>
        word
      </code>
      
      , <code>
        line-word
      </code>
      
       or <code>
        page-line-word
      </code>
      
      , or a form ending in <code>
        letter
      </code>
      
      , like <code>
        line-word-letter
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --pick <unit>
      </code>
    </td>
    
    <td>
      book, <code>
        word
      </code>
      
       or <code>
        letter
      </code>
      
      . A letter address needs none
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --start <n>
      </code>
    </td>
    
    <td>
      book, 1 or 0
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --iv <hex>
      </code>
    </td>
    
    <td>
      aes-cbc, aes-cfb, aes-ofb, aes-ctr, triple-des-cbc, rabbit, openpgp and zipcrypto (encode only)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --segment <bits>
      </code>
    </td>
    
    <td>
      aes-cfb
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --block-size <bits>
      </code>
    </td>
    
    <td>
      rijndael
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --nonce <hex>
      </code>
    </td>
    
    <td>
      aes-ccm, aes-ocb, salsa20, xsalsa20, chacha20, xchacha20, chacha20-poly1305
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --aad <hex>
      </code>
    </td>
    
    <td>
      aes-ccm, aes-ocb, chacha20-poly1305
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --counter <n>
      </code>
    </td>
    
    <td>
      salsa20, xsalsa20, chacha20, xchacha20, <code>
        0
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --tag-length <bits>
      </code>
    </td>
    
    <td>
      aes-ccm, aes-ocb
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --tweak <hex>
      </code>
    </td>
    
    <td>
      aes-lrw, aes-xts
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --digest <hash>
      </code>
    </td>
    
    <td>
      aes-passphrase (<code>
        md5
      </code>
      
      , <code>
        sha1
      </code>
      
      , <code>
        sha256
      </code>
      
      ), openpgp (up to <code>
        sha512
      </code>
      
      , encode only)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --algorithm <name>
      </code>
    </td>
    
    <td>
      openpgp, encode only
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --count <bytes>
      </code>
    </td>
    
    <td>
      openpgp, encode only
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --keys <hex>
      </code>
    </td>
    
    <td>
      zipcrypto, the three internal keys bkcrack prints, in place of <code>
        --key
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --entry <name>
      </code>
    </td>
    
    <td>
      zipcrypto, the file inside the archive
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --method <stored|deflate>
      </code>
    </td>
    
    <td>
      zipcrypto, encode only, <code>
        deflate
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --key-length <bits>
      </code>
    </td>
    
    <td>
      aes-passphrase
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --iterations <n>
      </code>
    </td>
    
    <td>
      aes-passphrase
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --salt <hex>
      </code>
    </td>
    
    <td>
      aes-passphrase, openpgp, encode only
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --endian <big|little>
      </code>
    </td>
    
    <td>
      rabbit
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --bytes <text|hex>
      </code>
    </td>
    
    <td>
      block and stream ciphers
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --rails <n>
      </code>
    </td>
    
    <td>
      rail-fence
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --width <n>
      </code>
    </td>
    
    <td>
      route
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --corner <corner>
      </code>
    </td>
    
    <td>
      route, <code>
        top-left
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --path <path>
      </code>
    </td>
    
    <td>
      route, <code>
        spiral-clockwise
      </code>
      
       by default
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --period <n>
      </code>
    </td>
    
    <td>
      alberti, bifid, trifid
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --letters <n>
      </code>
    </td>
    
    <td>
      bacon
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --lowercase <A|B>
      </code>
    </td>
    
    <td>
      bacon, decoding off letter case
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --a <n>
      </code>
      
      , <code>
        --b <n>
      </code>
    </td>
    
    <td>
      affine
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --positions <ABC>
      </code>
    </td>
    
    <td>
      enigma
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --rings <ABC>
      </code>
    </td>
    
    <td>
      enigma
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --plugboard "AB CD"
      </code>
    </td>
    
    <td>
      enigma
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        --preserve-case
      </code>
      
      , <code>
        --strip-non-alpha
      </code>
    </td>
    
    <td>
      caesar, rot13, atbash, substitution, affine, vigenere, gronsfeld, beaufort, porta, autokey, running-key, trithemius, alberti, quagmire-1 to quagmire-4, chaocipher, rail-fence, columnar, route. Case stays by default, <code>
        --no-preserve-case
      </code>
      
       gives capitals only
    </td>
  </tr>
</tbody>
</table>

`brute`, `frequency`, `period`, `guess`, `crib`, `hidden` and `recover` take `--lang`: `en`, `pl` or `ja`, English when you leave it out. `period` also takes `--max-period`, 20 by default. Longer key? Raise it.

`crib` takes the ciphertexts as one JSON array, the crib in `--crib`, the places accepted so far in `--known` as a JSON array of `{"message", "offset", "text"}`, and `--limit`, 10 places by default.

`hidden` takes `--pick`, `--letter`, `--every`, `--start` and `--direction` too. With `--pick`, `--lang` is ignored. One reading doesn't need ranking. The [analysis guide](https://ciphers.agntn.dev/guide/analysis#hidden-in-plain-sight) says which goes with which.

`recover` takes the cipher in `--cipher`, `--period` for Vigenère and both Beauforts, `--key-length` up to 9 for columnar, and `--limit`, 5 keys by default. Homophonic symbols written without separators take `--symbol-width`. All keys near misses? Use `--starts` and `--seed` to search further. Starts default to 8 and go up to 32.

## Exit codes and output

The output is the text the tool hands a model. For `encode` and `decode` that's the result alone, one line, so it composes:

```bash
ciphers rot13 "$(ciphers atbash "HELLO")"
```

`--json` prints the details instead: the cipher, the direction and every option it ran with. Handy when a default surprised you.

A `CipherError` prints its message to stderr and exits 1. Same for a missing key, an unknown cipher or a shift out of range, which the schema catches first. No stack trace. Anything else is a bug in the library and still gets one, on purpose. A bug should look like a bug.


## Sitemap

See the full [sitemap](https://ciphers.agntn.dev/sitemap.md) for all pages.
