# Worm encryption

This page extends the Snake cipher, by F. Ruiz, so it can be used with relatively short keys (hence the name) rather than keys three times the length of the plaintext. Snake simplified the paper-and-pencil TripleText cipher, also by F. Ruiz, so the Tabula Recta was used more efficiently. All steps can be performed by hand without excessive effort.

While Snake uses a non-repeating key text three times the length of the plaintext in order to generate the keystream, Worm uses a short repeating seed, as in the so-called Vigenère cipher, plus the plaintext and the ciphertext themselves after a delay equal to the length of the seed. After a short initial phase, letters are combined in groups of four as in the Snake cipher. The Tabula Recta includes a substitution determined by the main key (which can be different from the seed). This cipher is reciprocal like its predecessor, meaning that the process is identical for encryption and decryption. Unlike Snake, the Worm cipher can take a key or a seed that has been used before.

After the plaintext or ciphertext is 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— two additional rows are written below it to make a work table. Second row is the seed, repeated as many times as needed to equal the length of the plaintext. Third row is the ciphertext, which is computed differently while the number of its characters does not exceed the seed length (initial phase), this way:

1. For the initial phase, take the plaintext letter (top row), look it up on the top, bottom, or sides of the Tabula Recta, and then follow that row of column until the corresponding seed letter (immediately below the plaintext letter) is found, then follow that column or row, switching direction from the previous, to read the ciphertext letter on one of the edges. Keep doing this until you have used all the seed letters once.
2. Each ciphertext letter after this is the result of a four-letter "snake" operation on the Tabula Recta, where one starts looking up the first letter at the top or bottom, then up or down to the second letter, then right or left to the third, then up or down to the fourth, and finally right or left to read the result on the sides. Alternatively, one can start at the sides and read the result at top or bottom, switching direction with each new letter. Draw the letters in this order: first is the letter immediately above the spot to be filled; second, third, and fourth are the letters on the column one seed length left of the spot to be filled, read from top to bottom. Mark each column right after using it, so it is clear which is the next column to be used. Repeat this until the third row of the work table is as long as the others. This third row is the ciphertext (plaintext when decrypting).

### 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

Example 2-letter operations with straight alphabet: R + H = Q, E + W = S. Example 4-letter operations: Z + A + J + X = P, M + I + N + E = N.

## Step 1. Tabula preparation

The main key is for making the mixed alphabet at the top, bottom, and sides of the Tabula Recta. Do this to make a scrambled alphabet: 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 immediately preceding 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.

### Key

If you want to use a seed different from the key, write it in this box. Otherwise the key will be used as seed:

## Step 2. Plaintext preparation

### Plaintext / Ciphertext

For best security when encrypting, prepend a number of random characters (nulls) equal to the seed length

Now the message to be encrypted is converted to what follows after spaces, punctuation and diacritics are removed, and everything is turned into lowercase:

## Step 3. Encryption / Decryption

The next step is to obtain the ciphertext (plaintext, if decrypting). We generate the table below, following the instructions at the top of this page. The third row cannot be made right away but only after the computation has started, but here you will see it in its final state. The output (ciphertext or plaintext) is the third row. Some statistics will be displayed below the table.

### Work table

Information about output randomness will appear here

## Step 4. Encrypted Ciphertext / Decrypted Plaintext

The ciphertext (plaintext when decrypting) is repeated in the first box below. The lower box contains the same after splitting into codegroups of five characters each.