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.
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.
|Calculation Step 3||7||15||9||14||2||14||6||21||17||16||23||2||7|
Decryption requires knowing the exact order of the deck of cards.
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,...:
|Inverse Step 3||19||15||12||9||20||1||9||18||5|
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 (also)
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)
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 at second last 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.
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)
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.
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.
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 to practice a shuffle of the cards identical to the solitaire algorithm but by replacing the 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, a science fiction novel published in 1999. The algorithm was created by Bruce Schneier, cryptography consultant for this book.