Skip to main content

Solitaire Cipher

Bruce Schneier's Pontifex cipher that turns a deck of cards into a keystream.

The Solitaire Cipher, also known as Pontifex, was designed by Bruce Schneier for the novel Cryptonomicon. It uses an ordered deck of 54 cards (52 cards plus two jokers) to generate a letter-by-letter keystream. Provide an optional passphrase to key the deck before the keystream is produced; with no passphrase the deck starts in its natural 1 to 54 order. See more information on Wikipedia.

How it works

Solitaire turns a deck order into a keystream. Each letter advances the deck by moving the jokers, making a triple cut, making a count cut, and reading a card value from the top of the deck. Joker outputs are skipped.

Encryption adds the keystream values to the cleaned plaintext letters; decryption subtracts them from the cleaned ciphertext. The optional passphrase first keys the deck by applying the same deck moves once per passphrase letter with an extra count cut.