Home › Ciphers › Solitaire Cipher

Solitaire Cipher

In 1999 Bruce Schneier designed a complete stream cipher that needs nothing but a deck of playing cards — no electronics, nothing incriminating, just 54 cards and patience. He built it for Neal Stephenson's novel Cryptonomicon, where it appears under the codename Pontifex; its real name is Solitaire. The shuffled deck is the key: a permutation of 54 cards, worth about 238 bits of state. Each pass through the deck's little ritual — joker steps, a triple cut, a count cut — produces one keystream letter, which is added to the plaintext modulo 26 to encrypt, or subtracted to decrypt. This page performs the ritual exactly as Schneier published it, and proves it against his own test vectors below.

In short

The Solitaire cipher is a hand-worked stream cipher: a keyed deck of 54 cards is repeatedly shuffled by a fixed ritual to generate a keystream of numbers 1–26, added to the plaintext letters (mod 26) to encrypt and subtracted to decrypt. Sender and receiver must start from the identical deck — and never encrypt two messages with the same keyed deck.

Also called Pontifex, its codename in Cryptonomicon. Designed by Bruce Schneier, 1999.

Encode or decode — Schneier's Sample 3 is loaded

9 letters
Encoded · Solitaire · passphrase CRYPTONOMICON
KIRAK SFJAN

Keystream: 18, 20, 6, 18, 17, 18, 23, 18, 22, 16 · plaintext padded with X to a five-letter group

Everything runs in your browser — nothing is uploaded.

How it works

One ritual, one letter

Cards are counted in bridge order: clubs 1–13, diamonds 14–26, hearts 27–39, spades 40–52, then the A joker (53) and B joker (54). One round of the ritual: (1) move the A joker one card down — the deck is a loop, so a joker on the bottom wraps to just under the top card; (2) move the B joker two cards down, same wrap; (3) triple cut — swap the cards above the first joker with the cards below the second, leaving the jokers and everything between them untouched; (4) count cut — read the bottom card's value and move that many top cards to just above the bottom card, which itself stays put; (5) read the output card: count down from the top by the top card's value and take the next card. If it's a joker, the round is discarded and the ritual repeats — roughly one round in 26 dies this way. A surviving card becomes a keystream letter: its value, minus 26 if it's a heart or a spade.

Keying by passphrase (Schneier's method 3): start from bridge order, and for each passphrase letter run steps 1–4 followed by an extra count cut of that letter's value — the deck that remains is your key. Encryption adds keystream to plaintext letter by letter, wrapping past Z; the message is padded with X to a whole five-letter group, the field tradition, and transmitted in groups of five. Decryption runs the identical ritual and subtracts. The deck is the entire key, and it is consumed by use: the ritual that generates the keystream also destroys the starting arrangement, which is why two messages must never share a keyed deck.

Origin & history

A cipher written for a novel, meant in earnest

Neal Stephenson needed a cipher his characters could plausibly work by hand in Cryptonomicon (1999), and Bruce Schneier supplied one — published in the novel's appendix under his own name and documented on his website, with test vectors so implementers could check their work. Inside the fiction it is Pontifex; outside it, Solitaire. Schneier designed it to be taken seriously — aimed, in his words, at well-funded military adversaries — while needing nothing that would look like spy equipment: a deck of cards is the most innocent object in the world, and the algorithm is short enough to memorise and destroy. It remains the best-known hand cipher of the computer age, and the classic demonstration that a stream cipher is an idea, not a machine.

Reference

The ritual in five lines, and the published outputs

Step 1A joker down one (bottom wraps to just under the top card)
Step 2B joker down two, same wrap
Step 3Triple cut around the two jokers
Step 4Count cut by the bottom card's value; bottom card stays
Step 5Count down by the top card's value; the NEXT card is the output

Schneier's published raw outputs for the unkeyed bridge-order deck — the output cards of the first eleven rounds, before jokers are skipped: 4, 49, 10, 53, 24, 8, 51, 44, 6, 4, 33. The fourth round's output is a joker (printed 53, his convention for either joker) and produces nothing, which is why the usable keystream's fourth letter comes from the fifth round. This engine reproduces the sequence exactly.

Worked examples

The published test vectors

Example 1 — Schneier's three samples

Unkeyed bridge order: AAAAAAAAAAAAAAA → EXKYI ZSGEH UNTIQ · Key FOO: AAAAAAAAAAAAAAA → ITHZU JIWGR FARMW · Key CRYPTONOMICON: SOLITAIRE → KIRAK SFJAN

Schneier published three samples so implementers could check their work, and this tool reproduces all three exactly — they are part of the build suite, not a claim. Sample 3 is the loaded default above. To run Sample 1, choose "Unkeyed bridge order" and type fifteen A's; for Sample 2, keep passphrase keying and use FOO.

Example 2 — a short message on the unkeyed deck

HELLO → LBVJW (bridge order)

The unkeyed deck's keystream begins 4, 23, 10, 24, 8… — the raw outputs 4, 49, 10, (joker), 24, 8 with hearts and spades folded down by 26 and the joker round skipped. H+4 = L, E+23 = B, L+10 = V, L+24 = J, O+8 = W. It is a worked example, not a key: the unkeyed deck is public, so anything enciphered with it is readable by anyone — which is precisely why Schneier's samples use it only as a check.

Breaking it

An honest word about its strength

Solitaire was designed to be taken seriously, and for short hand-worked messages it remains respectable. But it is a 1999 design with known blemishes, and this page won't oversell it. Researchers have found small biases in the early keystream — the first outputs are not perfectly uniform — so very short messages leak a little more than they should. The passphrase is the soft underbelly: ordinary English carries roughly a bit and a half of randomness per character, which is why Schneier himself recommends passphrases of 80 characters or more, and why a genuinely shuffled deck, copied card-for-card to your correspondent, is the stronger key. Two of his operational rules are absolute: never encrypt two messages with the same keyed deck — with a reused keystream, the two ciphertexts combine into something a professional can pull apart — and keep messages short. For real secrecy today, use modern encryption; Solitaire's domain is the same as the deck it runs on: skill, demonstration, and proof.

  • Security status: strong for a hand cipher; dated as a modern one. No practical break of the full system is known, but the early keystream is measurably biased.
  • What gives it away: nothing in the ciphertext alone — the tells are operational: reused decks and long messages.
  • The working order: there is no shortcut attack to describe; the honest attack is on the keying — short passphrases are searchable.
Variants

Three ways to key the deck

RelativeHow it differsSolve it with
Passphrase keying (method 3)Bridge order shuffled by the passphrase ritual — convenient, weakest of the threeThe tool above, default mode
Shuffled-deck keyingA physically shuffled deck copied card-for-card — the strongest key the system offersThe tool above, Custom deck order
Bridge order (unkeyed)No key at all — the published check configuration, for test vectors onlyThe tool above, Unkeyed mode
VIC cipherThe other great hand system of the catalogue: checkerboard, lagged key, transposition — a full agent's kit rather than a single deckThe VIC page
Uses & culture

Pontifex in the wild

Beyond the novel, Solitaire became the reference example of a hand stream cipher: it is taught in cryptography courses as the bridge between classical systems and modern stream ciphers — the deck is a finite-state machine, the ritual its state update, the output card its keystream, and every concept (state, key scheduling, keystream reuse) has a modern namesake. It appears in puzzle hunts and CTFs as the "cipher with a deck of cards," and in the privacy literature as proof that serious cryptography needs no computer — and therefore cannot be controlled by controlling computers, a point Schneier has made about it more than once.

Practice

Run the ritual by hand

Practice 1 — decode EXKYI on the unkeyed deck

EXKYI → ?

Bridge order, no keying. The first five keystream letters are 4, 23, 10, 24, 8 — subtract them instead of adding.

Reveal the answer

AAAAA — the head of Schneier's Sample 1. E−4 = A, X−23 = A, K−10 = A, Y−24 = A, I−8 = A.

Practice 2 — why is the fourth keystream letter not from the fourth round?

Raw outputs: 4, 49, 10, 53, 24, …

Look at the published raw output sequence for the unkeyed deck in the Reference module and explain the gap.

Reveal the answer

The fourth round's output card is a joker — printed as 53 in Schneier's convention — and a joker round is discarded by design: a joker has no letter value, so counting it would break the 1–26 keystream. The fourth keystream letter (24) comes from the fifth round. It happens about once every 26 rounds on average.

FAQ

Frequently asked questions

Is Solitaire the same cipher as Pontifex?

Yes — Pontifex is the codename used inside Cryptonomicon; Solitaire is the name Schneier published it under, in the appendix he wrote for the novel and on his website. Same algorithm, same steps.

How secure is the Solitaire cipher?

Strong for a hand cipher, dated as a modern one. The deck state is huge (54! orderings, about 238 bits), and no practical break of the full system is known — but published analysis found small biases in the first keystream outputs, and a short passphrase collapses the key space to something searchable. Schneier's own guidance: shuffled-deck keys over passphrases, 80+ character passphrases if you must, a fresh key per message, short messages.

Why does my ciphertext end in X?

Because Schneier's convention pads the plaintext with X to a complete five-letter group before encrypting — field traffic was always sent in five-letter groups. On decode, the padding comes back as trailing X letters; they are part of the transmitted text, not an error. If your real message ends in X, the ambiguity is genuine and historical.

Can I encrypt with my own shuffled deck?

Yes — choose "Custom deck order" and type all 54 card values (1–52 in bridge order: clubs, diamonds, hearts, spades; 53 = A joker, 54 = B joker) in your deck's order, top card first. Your correspondent must start from the identical list. That is also how the system's strongest keys are made: shuffle a real deck well, copy its order twice, and never reuse it.

Next steps