# Tabula Prava

This page illustrates the "Tabula Prava" (Latin for "crooked table") human-computed symmetric encryption algorithm. It is a combination of the "alphabet" algorithm to generate a mixed alphabet from common text and the FibonaRNG cipher, which uses those to encrypt text with high security. The name derives from "Tabula Recta" (straight table), a square filled with letters, invented centuries ago, which is used in all phases of the process with small but important modifications.

The algorithm has these main steps:

1. Write the key phrase, minus spaces, diacritic marks, and punctuation, in three rows. For best results, there must be at least 180 letters so that each row contains a minimum of 60 letters. If the text is too short, repeat it until you get 180 letters in three rows of 60. If longer than 160, repeat to the next multiple of 3 and make three rows.
2. Combine the letters in each column of the table just formed, using a straight Tabula Recta like the one below, this way: look up the first letter at the top, then go down until the second letter is found, then left or right until the third letter is found, and then finally read the result at the top, and write it down. Examples: H + K = D; H + K + T = Q.
3. Convert the first 25 letters of the result into Mixed Alphabet 1 this way: 1, write down new letters in the order they appear; if a letter in the has already been written, write instead the first letter before it in the straight alphabet that is still available (wrap around to the end if needed); 2, then write the last letter still available. Then do the the same with the next 25 letters in order to produce Mixed Alphabet 2. The rest of the letters make up the Seed. Write Mixed Alphabet 1 at the left and right sides of the Tabula Prava, and Mixed Alphabet 2 at the top and bottom.
4. If encrypting, write a string of random letters as long as the Seed, which will become the random seed, and then the plaintext (with spaces, punctuation, and diacritics removed) immediately to its right. When decrypting, just write the ciphertext.Then take the Seed and write it at the start of the line below the plaintext.
5. If decrypting, extract the random seed from the ciphertext by following the process in step 7 just for those few letters, bearing in mind that you look up the top letters on the left or right of the Tabula Prava, and write into the bottom row the letter found at top or bottom of the table. Skip this step if encrypting.
6. Extend the seed (start of the first row if encrypting, of the third row if decrypting) into a keystream so all spaces in the second row are filled, this way: Look up the first keystream letter still available at the top or bottom of the Tabula Prava, then down until you find the letter that follows it in the keystream, then go left to read a letter on the right or left alphabet, which you will write in the next available position below the plaintext. Mark the first keystream letter you looked up so next time you start with the next letter. Notice that when encrypting you start taking letters from the top row, but when you run out of random seed you continue taking them from the second row, never from the plaintext itself.
7. When encrypting, do the following for each pair of letters consisting of a plaintext letter and the letter right below it: Look up the plaintext letter at the top or bottom of the Tabula Prava, then go up until you find the letter below, then right to read a letter on the right or left alphabet, which you will write below the pair of letters you involved in this operation, forming the ciphertext. For decryption, do the same but look up the first letter on the left or right instead, and read the result at top or bottom.

### 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 2. Write as three rows

Spaces, punctuation and diacritics are removed, and the text is written into three rows. Then each column is combined to yield a single letter through "serpentine" operations on the Tabula Recta.

### Processed Key Phrase

--------------------------

## Step 3. Derive Mixed Alphabets and Seed

Extract new letters first, or the immediately prior available letter if repeated. Alphabet 1 is made with the first 25 letters, Alphabet 2 with the next 25, the rest make the Seed (if you already the alphabets and seed, you can write them in directly):

### Seed

Place Alphabet 1 on the left side and right sides of the Tabula Recta, Alphabet 2 on the top and bottom, resulting in the Tabula Prava:

### Tabula Prava

  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 4. Plaintext preparation

### Plaintext / Ciphertext

Here is where we input the text to be encrypted (ciphertext if decrypting), which is converted to the following after spaces, punctuation and diacritics are removed, and everything is turned into lowercase:

## Steps 5 to 7. Encryption / Decryption

Since the process is different for encryption and decryption, we have to tell the program what we want to do:

Encrypt     Decrypt

In order to obtain the ciphertext or plaintext we generate the table below. The top row is the input, the middle row the keystream, the bottom row the output. The process to make it is described above.

### Work table

Information about output randomness will appear here

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