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!
Bruce Schneier's Solitaire encryption is a poly-alphabetic cipher whose encryption key is generated with a deck of cards.
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:
(Clover) Ace,2,3,…,10,J,Q,K equal to 1,2,3,…10,11,12,13
(Diameter) Ace,2,3,…,10,J,Q,K being 14,15,16,…23,24,25,26
(Heart) 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)
Clover > 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.
A message encoded by Solitaire has a coincidence index close to random.
All references to card games, bridge, the Solitaire game, or Freecell or the Cryptonomicon book and its author Bruce Schneier are clues.
The word pontifex is used as a code name in the novel.
The card game could be encoded in numbers in any other way provided that the sender and receiver agree on the method.
The original position of the card game is better if it is perfectly random, but it is possible to generate one from a keyword. Bruce Schneier describes a keyword-based method for mixing the deck by encoding it as in step 1 of the encryption. Then, it recommends practicing a shuffle of the cards identical to the solitaire algorithm but by replacing step 5 by a new step 4 where the cut is in position M with M a keyword letter code. Repeat all steps as well for each letter.
Optionally, the last 2 letters of the keyword (their codes $ c1 $ and $ c2 $) can be used to move the jokers respectively after the card in position $ c1 $ for the joker A and after the card in position $ c2 $ for the joker B.
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. Except explicit open source licence (indicated Creative Commons / free), the "Solitaire Cipher (Schneier)" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "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.) and all data download, script, or API access for "Solitaire Cipher (Schneier)" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Solitaire Cipher (Schneier)" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Solitaire Cipher (Schneier) on dCode.fr [online website], retrieved on 2024-11-21,