# SuperSkink encryption

This is a cipher based on Baise de Vigenère's classic autokey cipher, adding a substitution and involving four letters in each operation. The method is not identical for encryption and decryption, but almost so. In this implementation, the user can select two different substitution keys, plus a separate seed. SuperSkink is the Skink cipher with a transposition added at the end to protect against the known-plaintext attack. The transposition key and the seed must have different lengths in order to avoid statistical artifacts.

The first step is to generate a scrambled alphabet for each substitution key and the transposition key. The process is simple: 1, take the key and write down new letters in the order they appear; if a letter in the text key has already been written, write instead the first letter before it in the alphabet that is still available (wrap around to the end if needed); 2, then write the rest of the alphabet in reverse order (this is done only for the substitution alphabets, not for transposition). Place alphabet 1 on the top and bottom of the Tabula Recta, alphabet 2 on the left and right sides.

After the plaintext or ciphertext and the seed are processed —spaces and punctuation are stripped, and all letters are converted to capitals; accented letters are replaced by their non-accented versions; numbers in plaintext are converted to letters as in 0=A,1=B,...9=J, but are not converted back— we perform operations using the Tabula Recta on groups of four letters, this way to encrypt: find the first letter at the top and go down until the second letter is found, then left or right to the third, then up or down to the fourth, and finally left or right to read off the result. When decrypting, we will start on the left rather than the top, and read the result at the top or bottom. Now we discuss how to choose those letters for encryption and decryption. We start with the processed plaintext (ciphertext when decrypting) written out as a row of letters. Since the first phase has less security, you may want to prepend a number of gibberish letters equal to the length of the seed, the better to mask the seed against cryptanalysis.

The transposition step is done now when decrypting, at the end when encrypting. It goes like this when decrypting:

1. Take the third scrambled alphabet and write it down on checkered paper. Measure the length of the ciphertext up this point and divide that by key 3 length. Reserve as many empty rows below the alphabet as the integer result, rounded down, plus as many single cells below those, starting from the left, as the remainder.
2. Write the ciphertext in the reserved cells by columns, top to bottom, following the order marked by the alphabet: first the "A" column if any, then "B", and so forth, filling each column completely (some columns are longer than others).
3. After filling all the reserved cells, read them off by rows, starting from the top, left to right. This is the descrambled ciphertext.

If you are going to add nulls to protect the seed (when encrypting), this is the time to do it. Prepend as many random characters as the length of the seed before the plaintext.

Encryption, starting from the plaintext:

1. Take the seed and write it directly above the plaintext, beginning with the leftmost position.
2. Take the first plaintext letter, look it up on the top or bottom of the Tabula Recta, and go down or up until the seed letter directly above that letter is found, then left or right to the edge. Write that letter below the plaintext letter. Then take the second plaintext letter and do the same, this time using the second seed letter, and so on. When this phase is over, the row below the plaintext will contain the same number of letters as the seed.
3. Now the pattern changes: take the letter immediately above the spot we want to fill and look it up at the top or bottom of the Tabula Recta, then go down until the first plaintext letter (top row) is found, then left or right to read the second plaintext letter, then up or down to read the first ciphertext letter (immediately below the first plaintext letter), then left or right to read the result at the edges. Mark the first plaintext letter so you don't use it again. Then take the next letter and do the same, this time involving the second plaintext and third letter, on the top row, and the second ciphertext letter, on the bottom row. Keep repeating this step while the bottom row is shorter than the top row. When done, the bottom row is the ciphertext, which needs to be scrambled next.

Decryption starting from the ciphertext is nearly identical to encryption, except that operations on the Tabula Recta start on the sides rather than at the top, and in step 3 the second and third letters of each operation are taken from the bottom row, and the fourth from the top row:

1. Take the seed and write it directly above the descrambled ciphertext, beginning with the leftmost position.
2. Take the first (descrambled) ciphertext letter, look it up on the left or right of the Tabula Recta, and go right or left until the seed letter directly above that letter is found, then up or down to read the result. Write that letter below the ciphertext letter. Then take the second ciphertext letter and do the same, this time using the second seed letter, and so on. When this phase is over, the row below the ciphertext will contain the same number of letters as the seed.
3. Now the pattern changes: take the ciphertext letter above the spot to be filled and look it up on the left of the Tabula Recta, then go right until the first plaintext letter (bottom row) is found, then up or down to the second plaintext letter, then left or right to the first ciphertext letter (top row), and then up or down to read the result at top or bottom. Mark the first plaintext letter so you don't use it again. Then take the next letter and do the same, this time involving the second and third plaintext letters, on the bottom row, and the second ciphertext letter. Keep repeating this step while the bottom row is shorter than the top row. When done, the bottom row is the plaintext, perhaps preceded by a few gibberish characters.

When encrypting, end with a transposition, this way:

1. Take the third scrambled alphabet and write it down on checkered paper.
2. Write the result of the previous step in the cells below the alphabet by rows, left to right and top to bottom.
3. Finally, read them off by columns, following the order marked by the alphabet: first the "A" column, then "B", and so forth. This is the scrambled ciphertext.

### Tabula Recta

  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
---------------------------------------------------
A | A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | A
B | B C D E F G H I J K L M N O P Q R S T U V W X Y Z A | B
C | C D E F G H I J K L M N O P Q R S T U V W X Y Z A B | C
D | D E F G H I J K L M N O P Q R S T U V W X Y Z A B C | D
E | E F G H I J K L M N O P Q R S T U V W X Y Z A B C D | E
F | F G H I J K L M N O P Q R S T U V W X Y Z A B C D E | F
G | G H I J K L M N O P Q R S T U V W X Y Z A B C D E F | G
H | H I J K L M N O P Q R S T U V W X Y Z A B C D E F G | H
I | I J K L M N O P Q R S T U V W X Y Z A B C D E F G H | I
J | J K L M N O P Q R S T U V W X Y Z A B C D E F G H I | J
K | K L M N O P Q R S T U V W X Y Z A B C D E F G H I J | K
L | L M N O P Q R S T U V W X Y Z A B C D E F G H I J K | L
M | M N O P Q R S T U V W X Y Z A B C D E F G H I J K L | M
N | N O P Q R S T U V W X Y Z A B C D E F G H I J K L M | N
O | O P Q R S T U V W X Y Z A B C D E F G H I J K L M N | O
P | P Q R S T U V W X Y Z A B C D E F G H I J K L M N O | P
Q | Q R S T U V W X Y Z A B C D E F G H I J K L M N O P | Q
R | R S T U V W X Y Z A B C D E F G H I J K L M N O P Q | R
S | S T U V W X Y Z A B C D E F G H I J K L M N O P Q R | S
T | T U V W X Y Z A B C D E F G H I J K L M N O P Q R S | T
U | U V W X Y Z A B C D E F G H I J K L M N O P Q R S T | U
V | V W X Y Z A B C D E F G H I J K L M N O P Q R S T U | V
W | W X Y Z A B C D E F G H I J K L M N O P Q R S T U V | W
X | X Y Z A B C D E F G H I J K L M N O P Q R S T U V W | X
Y | Y Z A B C D E F G H I J K L M N O P Q R S T U V W X | Y
Z | Z A B C D E F G H I J K L M N O P Q R S T U V W X Y | Z
---------------------------------------------------
  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

## Step 1. Tabula preparation

We begin by making scrambled alphabets out of the keys, which are then placed at the top, bottom, and sides of the Tabula Recta. This is why we input the keys before the plaintext. The boxes are blue to indicate that they can be written on. Do this to make a scrambled alphabet: take each key and write the different letters of the alphabet in the order they appear in the key, if a letter has been used already, write instead the immediately preceding letter in the normal alphabet not yet chosen; if there are letters that did not appear in the key, write them now in reverse alphabetical order (keys 1 and 2 only).

It is OK to use keys that have been used before, even for a message of identical length as a previous message. In this program, if you leave the key 2 or key 3 boxes empty, key 1 will be used also in those roles. Write a single letter in the key 3 box to turn off transposition.

### Key 3 (transposition)

If you want to use for the seed phase a key different from key 1, write it in this box, otherwise key 1 will be used:

### Seed

Since the processes for encryption and decryption are slightly different, we need to tell the program what we want to do:

Encrypt     Decrypt

Here we tell the program whether or not to prepend some gibberish to the plaintext in order to mask the seed:

## Step 2. Plaintext preparation

### Plaintext / Ciphertext

Which is converted to this, after spaces, punctuation and diacritics are removed, and everything is turned into lowercase:

### Processed Plaintext / Ciphertext

If we are decrypting, the ciphertext is descrambled using Key 3 as transposition key. This is the result (same when encrypting, except perhaps adding nulls to mask the seed):

## Step 3. Encryption / Decryption

In order to obtain the ciphertext we generate the table below, following the instructions at the top of this page. The bottom row is the output. If adding nulls to the plaintext, they are added at this point.

### Work table

Information about output randomness will appear here

## Step 4. Encrypted Ciphertext / Decrypted Plaintext

When encrypting, we do a transposition as final step, using Key 3 as key. We begin with the result of the previous operation, which will be repeated if we are decrypting instead (transposition was done earlier).

The ciphertext (plaintext when decrypting, with initial null removed) is the first box below. The lower box contains the same, but split into codegroups of five characters each.