Triple Text 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 standard Tabula Recta below, letter by letter, first the first and second piece, then the result and the third piece to obtain the keystream. Finally the plaintext (ciphertext, when decrypting) is subtracted letter by letter from the keystream.

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

To add two letters: find one letter on the top and the other on the left side; follow the column and row, respectively; the letter found on intersection of the two is the sum. Example (with default table): R + H = Y. To subtract two letters: find the first letter on the top and the second letter (the one being subtracted) on the right side; follow the column and row as for addition. Example (with default table): 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. 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: take the first sentence in the key text (up to the first period), and write the different letters of the alphabet at the top of the table in the order they appear in the text; if there are letters that did not appear in that sentence, write them now at the top of the table in reverse alphabetical 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 at the top 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 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