## On the Subject of the Solitaire Cipher

It's not a game anymore, it's a cipher now.

On the screen currently, you'll see a 6 letter encrypted word at the top with a submission cursor on the bottom.

Pressing the blue circular button will toggle the screen to a new page. This new page will consist of 27 characters, 25 of them being A - Y, and the other 2 being 1 and 2. This is the key used to encrypt the word. Pressing the button again will bring it back to the other screen.

The green circular button will submit any input you made while the red circular button will clear all input.

Submit the decrypted word to disarm the module.

### Cipher Mechanics

For each letter, this cipher makes it go through 2 steps: Shuffle and Encrypt.

It first shuffles the key around using a set of instructions. Then encrypts the letter using Vigenere as it's main method. Thus, this creates a running keystream that seems random.

Fear not! For the instructions below will explain how the shuffling and decrypting process works.

### Shuffle Step

1. Shift the character 1 to the right once, wrapping around if necessary.
2. Shift the character 2 to the right twice, wrapping around if necessary.
3. Swap the characters to the left of the leftmost number with the characters to the right of the rightmost number.
4. Count off the number of characters on the left equal to the alphanumeric position of last character of the key.
5. Take these characters and insert them inbetween the 2nd to last and last character of the key.

The steps above can be simplified to this to make it easier to remember: Shift 1 and 2, Triple Cut, Count Cut.

### Decrypt Step

1. Count off the number of characters on the left equal to the alphanumeric position of the first character of the key.
2. Take note of the character AFTER the characters you counted in the key.
3. Subtract the alphanumeric position of the encrypted letter by the alphanumeric position of the character you got from the previous step.
4. Take this number, add 26 until it's a number between 1 - 26, and turn it back into a letter.

### Extra Things

If the resulting character you got from any step was 1, use the 3rd character of the serial number, plus 1.

If the resulting character you got from any step was 2, use the 6th character of the serial number, plus 1.

The shifting of the 1 and 2 in this module isn't accurate to how the cipher is actually done. The cipher treats the key as if it was a giant circle. That meant when 1 or 2 was at the bottom, it would shift OVER the 1st character of the key. But I decided it to make it more "consistent" so that little part wouldn't trip you up every time that would occur.

#### Example

DVTGXBQRFKMJLCEN21IWAUHOYSP

Shift 1 and 2

DVTGXBQRFKMJLCENI12WAUHOYSP

Triple Cut

WAUHOYSP12DVTGXBQRFKMJLCENI

Count Cut

2DVTGXBQRFKMJLCENWAUHOYSP1I

2 is the first character, the 6th character of the Serial Number is 1.
Count off the 2 characters, the character afterward is V.
Q - V = -5 + 26 = 21 -> U