[Home][FAQ Details]

[Computer Stuff][Products]

Encryption - Using More Than One Alphabet

We noted earlier that it is the word frequencies that are fairly constant for a given language that give away the code to the unauthorised reader in a scrambled alphabet. One way to do this is to use different alphabets. Here, this means that we do not simply use the regular order of the alphabet (abcdef), but have others in a different order. This scheme was first devised by the Frenchman, Vigenère

We can illustrate this better with an example. Let us choose a password "Harry". First we start with the regular alphabet, and write under it the same alphabet, but beginning with each letter of the password:

Plain A B C D E F G H I J K L M
Cipher  H I J K L M N O P Q R S T
A B C D E F G H I J K L M
R S T U V W X Y Z A B C D
Y Z A B C D E F G H I J K
Plain N O P Q R S T U V W X Y Z
H(cont) U V W X Y Z A B C D E F G
A(cont) N O P Q R S T U V W X Y Z
R(cont) E F G H I J K L M N O P Q
Y(cont) L M N O P Q R S T U V W X

The top alphabet, in bold, is the plain text alphabet. The first alphabet below the plain text is the H alphabet. This begins with H and continues as usual. Next come the A and the R alphabets, which begin with the named letter and continue. We drop the second R in Harry, and continue with the Y alphabet.

We could have written all 26 alphabets, each beginning with A, B, C, etc, but as we will use only the ones in the password, we write only the necessary ones.

This scheme uses a polyalphabet.

How to Encipher a Message Using the Different Alphabets

Suppose we wish to encode the following:

"Keep well"

First we group the letters according to the length of the password ("Harry" is 4, omitting the repeated letters):

"Keep well"

The first letter in each group is encoded with the first (the H) alphabet). The second with the second alphabet (the A alphabet), and so on. So, K is encoded as R, e as E, etc. The encoded message is:

"REVN DECJ"

The example shows that it is a good idea to avoid passwords containing A, because that is the regular alphabet.

It also shows that the same letter in the plain text is not always encoded with the same letter in the cipher text. In this example, the two e's in the plain text are enciphered differently in the cipher text.

Because the third "e" occurs 4 letters from the first one, it is enciphered in the same way as the first "e".

Scrambling the Alphabets

We have used regular alphabets in the example, but we could have made things harder for the unauthorised reader by scrambling the alphabets. If we did this, then the principles above would be the same, but when we used, say, the H alphabet, it would start with an H, but the order would follow the scrambled alphabet. For example, we can write a scrambled alphabet for Harry:

HARYBCDEFGIJKLMNOPQSTUVWXZ


HARY
BCDE
FGIJ
KLMN
OPQS
TUVW
XZ

Writing the columns we get

HBFKOTXACGLPUZRDUMQVYEJNSW

We use this to make our alphabets. The H alphabet is the same as the scramble above. The A alphabet is:

ACGLPUZRDUMQVYEJNSWHBFKOTX

And so on ....

Program

The program below uses the same principles as the example above. Unlike the example above, it uses all 95 printable characters in Windows as its alphabet. The text and the password are case sensitive. This example, does not use a scrambled alphabet.

I used the password "Harry", and the same text as before.

Text to Encode (or Decoded Text)


Password Length

Password

Text to Decode (or Decoded Text)




The following code resulted:

c-6%3#1J;325|*+9;5$>4-4,!<43"< >B?D>#-+,,5$$; 8>|<2)5<%)$31%;,4-}#1L;`..B2='"2=$|3-4""=("0$?;u.5;"..B2=(|4$>1-=$,<3(&1I>6-42;##)1-1>4'+,;".>&2=&,0=9,3I>,0=9,3D,)</) )=!;!.,,31>+},%;$1/*<3("<"(|03?;p')0<-5* $2;"$3 0(""1=4%#=%5}"4;!.,,31>6-4>4}-4I<

j/02=foii>""(4,02>4'+,;}+,,5=9,3=4,<2%)#"4;}=#,*.5/< .!<3("<$$&2.2;5(,)</51<3("<-5* $20<(.;$.2;7.5I<q("< ,1#1.|2(6"<(3;2.>0#+% 2=4%#=#,*.5/1=&/-,>|<3!}*$>4&(#%<2(,52>|</) 242"< .!<3("<'%5}#% ',!)<"/)-42;!.$"<Eg;21)""=4,< 6,'#>0}8)+%=("6 $"!(-|*>>d<#)!,D4;5 .1<8/2<*.,5=7%}3>|<%/2*=-,33(""=0"02/+<f>4}2?;^44;e=32.//0#=4%#=4/33(;5(,)<.51==w,3=$,,D4;,$%!<3/;)-/4<6(|2=("6 $"!(-|*=-"}-3G< .!<(&;7.5;}1%+C3>|<,!1&$-|2(#&}-J;"..B2=4/7K>e324;2 +"<(4;2'!1<3(&1=)0< >#3-.6<-5* $2;5(4%<+%12$20H=//< > -#%G<3(|2=4%#=foii>""(4,0=//< >1}!,"<&)3#2>6-4>1-=-|)$>6-42;-6.;3-).3$> -+/20K>k#13,, ,)7I>d< ,4}83;32%;}->""(4,0=4%}3>-333;2'%;,4-}#1>&,=&,0=-"JF>o&(3;!.$"<&)3#2>|<,)5242"<.&;0$$G<&2"#->|,#>}*4%;2.>*}*%;7.5/<20"!(!)<"/)-42<

The following are the top frequencies in the above code:

Character 60 (<) occurs 58 times.

Character 44 (,) occurs 52 times.

Character 50 (2) occurs 51 times.

Character 34 (") occurs 47 times.

Character 51 (3) occurs 45 times.

Character 52 (4) occurs 45 times.

You may notice that the frequencies are very similar. Gone are the extremes of natural language, which have been averaged over the alphabets.

The space does not appear as a clear high frequency element. The frequency is much flatter because it is the average of several alphabets.

Below is a list of all the repeating patterns of length 11:

Solving the Vigenère

We can solve the Vigènere style crypt that uses polyalphabets by firstly finding the length of the password and then extracting the alphabets and unravelling them. Easily said ...

Finding the Length of the Password

The numbers in the above list of repeating patterns are the positions of the pattern in the text. For example, the pattern, "=foii>""(4," occurs at 254 and 754, so the difference is 500. Similarly we note:

500, 500, 132, 132 ..

We factorise these distances between repetitions:

500=5x4*25

132=4x33

The common factor is 4, which may be the length of the password.

Dividing the Cipher into its Original Alphabets

If the password length is 4, then the alphabets are reused every fourth character, so by putting the text into 4 columns, we have a list of the cipher encoded in each alphabet. Using the first part of the code, we have:

c - 6 %
3 # 1 J
; 3 2 5
| * + 9

The characters

c 3 ; |

in the first column, may be in the same alphabet. If so, we may be able to use letter frequencies, etc, to solve

If the original alphabets have been scrambled, then we would use the techniques for unscrambling jumbled alphabets.

Even when we use multiple alphabets, we can find a rout to decipher them, even if the original alphabets are scrambled.

Summary

While polyalphabetical systems are better than previous ones, they still have a rout to unauthorised inspection. As attempt to improve matters, other techniques, such as the Playfair cipher were used.