Tool to decrypt / encrypt with Solitaire by Schneier. Solitaire is a cryptographic cipher using a deck of cards, invented by Bruce Schneier in the roman Cryptonomicon.
Solitaire Cipher (Schneier) - dCode
Tag(s) : Poly-Alphabetic Cipher
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The Solitaire cipher, devised by Bruce Schneier, is a polyalphabetic encryption algorithm that uses a deck of cards as a key generator.
This system was designed to be used without electronic equipment while still providing a reasonable level of security.
To encode a message with Solitaire, the deck of cards is used to generate a sequence of numbers that will be used as a key to produce an encrypted message.
Example: Encrypt the message CRYPTONOMICON with the unmixed card game 1,2,3,4…,52,A,B
Step 1: Associate with each character of the message a number like A=1,B=2,…Z=26 (code A1Z26)
Example: C has the value 3, R becomes 18, Y becomes 25, etc.
Step 2: Generate a code (keystream) by mixing the card game according to the solitaire algorithm (see below)
Example: The first code obtained is 4 (then 49, then 10, etc.)
Step 3: Add two by two the numbers of steps 1 and 2. If the total obtained is greater than $ 26 $, subtract $ 26 $.
Example: $ 3+4=7 $, then $ 18+49=67 $, as $ 67 > 26 $ calculate $ 67-26=41 $ and again $ 41-26=15 $ etc.
Step 4: Replace each number by the letter corresponding to it (inverse operation of step 1), 1=A,2=B,…26=Z. The letters obtained correspond to the encrypted message.
Example:
Plain text | C | R | Y | P | T | O | N | O | M | I | C | O | N |
Coded letters | 3 | 18 | 25 | 16 | 20 | 15 | 14 | 15 | 13 | 9 | 3 | 15 | 14 |
Card Keystream | 4 | 49 | 10 | 24 | 8 | 51 | 44 | 6 | 4 | 33 | 20 | 39 | 19 |
Calculation Step 3 | 7 | 15 | 9 | 14 | 2 | 14 | 6 | 21 | 17 | 16 | 23 | 2 | 7 |
Cipher text | G | O | I | N | B | N | F | U | Q | P | W | B | G |
Decryption requires knowing the exact order of the deck of cards used for encryption.
Decryption is the same as encryption, except for step 3 where you do not add but subtract from each number the one generated by the deck of cards. If the number is less than $ 1 $, add $ 26 $.
Example: Decrypt VQMLVBLTF with generated codes (dummies) 3,2,1,3,2,1,…:
Cipher text | V | Q | M | L | V | B | L | T | F |
Coded letters | 22 | 17 | 13 | 12 | 22 | 2 | 12 | 20 | 6 |
Card keystream | 3 | 2 | 1 | 3 | 2 | 1 | 3 | 2 | 1 |
Inverse Step 3 | 19 | 15 | 12 | 9 | 20 | 1 | 9 | 18 | 5 |
Plain text | S | O | L | I | T | A | I | R | E |
Bruce Schneier describes an unmixed card deck with the following numbers:
(Clubs) Ace,2,3,…,10,J,Q,K equal to 1,2,3,…10,11,12,13
(Diamonds) Ace,2,3,…,10,J,Q,K being 14,15,16,…23,24,25,26
(Hearts) Ace,2,3,…,10,J,Q,K being 27,28,29,…36,37,38,39
(Spades) Ace,2,3,…,10,J,Q,K being 40,41,42,…49,50,51,52
Joker A, Joker B worth respectively A or 53, B or 53 (yes, not 54)
Club > Diamond > Heart > Club is the order of the game used in the rules of the Bridge game
The generation of codes is the most complicated part of the Solitaire code, it involves a precise mixture.
Example: 2,6,A,3,4,5,1,7,8,…,B,9 is a set of 54 cards (with separate wildcards A and B) in this modified starting position
Step 1: Move the joker A by 1 card below in the stack (which is to exchange the joker A with the card immediately below). If this is not possible, ie. if the joker A is at the bottom of the stack (so it does not have a card underneath), then move it on top of the stack and apply step 1 (so it will become the second card of the deck)
Example: 2,6,3,A,4,5,1,7,8…,B,9
Step 2: Move the B joker by 2 cards underneath into the stack. Again if it is not possible, if the joker B is at the bottom of the pile, then move to position 3 (it will have 2 cards above) or if the joker B is in penultimate position, then move it to position 2 (1 card above it). This comes down to considering that the card game is a loop on itself.
Example: 2,B,6,3,A,4,5,1,7,8,…,9
Step 3: Make a triple cut at the level of the jokers (the jokers and all the cards between them do not move but the groups of cards before and after exchange, even if a group is empty)
Example: 1,7,8,…9,B,6,3,A,4,5,2
Step 4: Cut after the Nth card where N is the number corresponding to the card at the bottom of the stack, leaving this last card in its place. If the last card is a joker, do not change anything at this stage.
Example: 1,7,8,…9,B,6,3,A,4,5,2
Step 5: Note the number X of the card in the N+1 position where N is the number corresponding to the top card of the stack (which is in position 1). X is the generated code (the deck is not mixed at this stage).
Example: 1,7,8,…9,B,6,3,A,4,5,2 The first code is 7
Repeat steps 1-5 to obtain the following code of the keystream.
Messages encrypted using this method exhibit a coincidence index close to that of random text, making them difficult to analyze using conventional cryptanalysis.
Clues link this cipher to the world of cards: references to bridge, the game of Solitaire, Freecell, and even the novel Cryptonomicon in which it appears.
In this book, the word pontifex refers to this cipher as a code name.
The deck of cards used can be represented by numbers in various ways, provided that both the sender and the recipient use the same matching system.
Ideally, the deck should start with a perfectly random order. However, an initial order can be generated from a keyword. Bruce Schneier proposes a method for this: the keyword is converted into a series of cipher steps, as in the first phase of the algorithm. The deck is then shuffled, following the classic Solitaire cipher steps, but with one modification: step 5 is replaced by a new version of step 4, in which the cut is made at the position corresponding to the code for the letter of the keyword. This process is repeated for each letter of the keyword.
Optionally, the last two letters can be used to move the jokers: the code for the penultimate letter determines the position for the A joker, and that for the last letter indicates the position for the B joker.
Neal Stephenson describes the Solitaire algorithm in Cryptonomicon here (affiliate link) a science fiction novel published in 1999. The algorithm was created by Bruce Schneier, cryptography consultant for this book.
dCode retains ownership of the "Solitaire Cipher (Schneier)" source code. Any algorithm for the "Solitaire Cipher (Schneier)" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Solitaire Cipher (Schneier)" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Solitaire Cipher (Schneier)" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Solitaire Cipher (Schneier)" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Solitaire Cipher (Schneier) on dCode.fr [online website], retrieved on 2025-05-24,