# Schneier’s solitaire cipher

Posted by Doug Hull,

I have liked cryptography since I was sending Caesar cipher messages to my fellow 6th graders. The essence of that was to ‘add’ a value to each letter of your message. With Caesar, it was a constant value. With a one time pad they are pattern-less values, but they have to be stored. With Bruce’s algorithm, the values to be added to your message are generated by an algorithm. Know the starting state of the algorithm, and you can generate the values, or keystream. All the security lies in the ‘key’ or starting state. Since this algorithm works on a deck of cards, there are factorial(54) starting states. That is a lot. The example below will only use a six card deck.

In some ways, this is a lot like a pseudo-random number generator: The values are only random to the uninitiated. In this series, we will implement the algorithm, and analyze the output of the algorithm.

The algorithm will rearrange the cards. Since for a six card problem, there are 720 states for the cards to be in we can say for certainty that after 721 iterations, we will have repeated a state. The question is does it take that long, or are their smaller loops? How many loops or cycles are there?

Here is the Cody problem, so watch the video to see the algorithm and try to implement it.

What is 7 + 9?

Preview: hide

These postings are the author's and don't necessarily represent the opinions of MathWorks.