Summary | The Somewhat Simplified Solitaire (SSSolitaire) Encryption Algorithm -- Bruce Schneier created the card-deck-based Solitaire encryption algorithm for Neal Stephenson's novel "Cryptonomicon." A slightly reduced version of Solitaire requires little more than basic list operations and provides an introduction to encryption. |
Topics |
Linear data structures; encryption. |
Audience |
Accessible by students from late CS1; more appropriate for CS2. |
Difficulty |
Moderate |
Strengths |
What I like about the assignment is that it is inspired by an algorithm that is a key element in a work of fiction. Not only does implementing the algorithm give the students exposure to encryption and practice with list manipulation, it can also encourage students to pick up the novel! |
Weaknesses |
Simplifying Solitaire no doubt creates an algorithm that is less resistant to cryptographic attack, but for CS1/CS2 students that isn't much of a problem. |
Dependencies |
Students need to be able to handle list manipulations, perform input from a text file (if they will be expected to read card decks from a file), and accept that large, complex algorithms are often merely composed of small, simple algorithms. |
Variants |
Here are three ideas: (1) Vary the number of cards in the deck. I use 28, which works well with the upper-case letters. but one could use 38 to include decimal digits. (2) The algorithm steps can be adjusted in any number of ways. (3) More advanced students could perform basic statistical analyses of the algorithm or any variation. See the PDF of the talk for some additional ideas. |
1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 27 2 5 8 11 14 17 20 23 26Step 1: Swap 27 with the value following it. So, we swap 27 and 2:
1 4 7 10 13 16 19 22 25 28 3 6 9 12 15 18 21 24 2 27 5 8 11 14 17 20 23 26 ^^^^Step 2: Move 28 two places down the list. It ends up between 6 and 9:
1 4 7 10 13 16 19 22 25 3 6 28 9 12 15 18 21 24 2 27 5 8 11 14 17 20 23 26 ^^^^^^Step 3: Do the triple cut. Everything above the first joker (28 in this case) goes to the bottom of the deck, and everything below the second (27) goes to the top:
5 8 11 14 17 20 23 26 28 9 12 15 18 21 24 2 27 1 4 7 10 13 16 19 22 25 3 6 ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^Step 4: The bottom card is 6. The first 6 cards of the deck are 5, 8, 11, 14, 17, and 20. They go just ahead of 6 at the bottom end of the deck:
23 26 28 9 12 15 18 21 24 2 27 1 4 7 10 13 16 19 22 25 3 5 8 11 14 17 20 6 ^^^^^^^^^^^^^^^Step 5: The top card is 23. Thus, our generated keystream value is the 24th card, which is 11.
Extra info about this assignment: