TripleText encryption

© Francisco Ruiz, 2015

This page simplifies the paper-and-pencil BookPad cipher by F. Ruiz so no encoding is used. Instead, operations are carried out directly on the text by means of a Tabula Recta, which implements addition and subtraction mod 26 over a 26-letter alphabet. All steps can be performed by hand without excessive effort.

We will use a piece of key text three times the length of the plaintext (after spaces and punctuation are removed) in order to generate a "one-time pad" of sorts by concentrating the entropy inherent in the key text to match that of a perfectly random text. The key difference between this cipher and the classic running key cipher is that the latter uses a piece of key text of the same length as the plaintext, which is less than perfectly random and can be attacked by making guesses from a dictionary. As dictionary words, or parts thereof, are obtained when other dictionary words are subtracted from the ciphertext (at different positions in the ciphertext), then both the plaintext and the key text are gradually recovered at the same time. This is not possible with the triple text cipher.

Theoretical unbreakability is achieved when the keystream used to encipher the plaintext has the same entropy as a random string of the same length, according to Shannon's criterion for perfect secrecy. Since there are 26 possible letters, the entropy of a perfectly random string or letters is log(26)/log(2) = 4.70044 bits/letter. Since English text, according to Shannon, has an average entropy of 1.58 bits per character (spaces are included, so the entropy per letter is a little higher), a piece of text of length 4.70044/1.58 = 2.975 times the length of a given random string contains the same entropy. If the text is three times as long as the plaintext, therefore, its entropy can match that of a random string of plaintext length.

The process is identical for encryption and decryption. 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— a piece of equally processed key text three times as long as the processed plaintext or ciphertext is selected and split into three parts of equal length. Those are added mod 26 using the Tabula Recta below, letter by letter, first the first and second piece, then the result and the third piece to obtain the keystream. If a key-derived alphabet is used, rather than the straight alphabet, this operation also involves a substitution of the letters in the second term of the sum. Finally the plaintext (ciphertext, when decrypting) is subtracted letter by letter from the keystream (and substituted, if the alphabet is not the straight one). Using an alphabet derived from the key text makes the final ciphertext non-malleable.

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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
    ---------------------------------------------------
    a z y x w v u t s r q p o n m l k j i h g f e d c b

To add two letters: find the first letter on the left side and the second on the top; then follow the row and column, respectively; the letter at the intersection of the two is the sum. Example with straight alphabet: R + h = Y. To subtract two letters (as in subtracting the plaintext from the keystream or the ciphertext from the keystream): find the first letter on the left and the second letter (the one being subtracted) on the bottom, and then follow those row and column to find the result at the intersection. Example with straight alphabet: R - h = K.

 

Step 1. Tabula preparation

We begin by making a scrambled alphabet out of the key text, which is placed at the top of the Tabula Recta, and then repeated in the body itself. This is why we input the key text before the plain text. The box is blue to indicate that it can be written on. Do this to make a scrambled alphabet: 1, take the first sentence in the key text (up to the first period) and write down new letters in the order they appear; if a letter in the key text 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. Then the Tabula Recta is filled by taking the top line and copying it below, and then displacing it cyclically to the left by one letter in each successive row. The bottom line, which is used for subtractions, is made from the top line this way: the first letter is the same, and then follow with the rest of the letters on the top line, in reverse order.

When a plaintext is written, the key text is processed in the same way as the plaintext (capitals rather than lowercase) and a piece of it one letter longer than the processed plaintext, is taken and placed in the seed box . If it is too short, it will be repeated and a warning will appear below the key text. This key text will be used to encrypt the plaintext (or decrypt the ciphertext), and then it will never be used again.

Key Text

This is where the warning will appear

Let us also select whether the alphabet that forms the basis of the Tabula Recta will be scrambled according to the key text, or the straight alphabet will be used:

  Key text-derived alphabet     Straight alphabet

 

Step 2. Plaintext preparation

Now the message to be encrypted.

Plaintext / Ciphertext

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

Processed Plaintext / Ciphertext

 

Step 3. Keystream Generation

The next step is to generate the keystream. In this version, we can enter in the box below a variable multiplier for the key text length. Typically, 3 times the plaintext length is enough.

Key Text length factor

Allowed values are 1 to 9. This is how many times the key text is longer than the plaintext.

First we take a piece equal to that many times the length of the processed plaintext. Then we split the result into as many parts of equal length, resulting in this:

Processed Key Text

And then we add them letter by letter using the Tabula Recta in order to obtain the keystream.

Keystream

Information about keystream quality will appear here

 

Step 4. Encrypted Ciphertext / Decrypted Plaintext

We now use the Tabula Recta to subtract and encode letter by letter the processed plaintext (ciphertext, when decrypting) from the keystream, resulting in the ciphertext (plaintext, when decrypting). The lower box contains the same, but split into codegroups of five characters each.

Ciphertext / Plaintext

Formatted output