After the simple Caesar cipher had been around for a few thousand years there came a man by the name Blaise de Viegnere. Naturally he was a cryptographer, and his new algorithm would return cryptanalysts to the top of the chain, as it would baffle cryptanalysts with its seemingly random output. His encryption algorithm was revolutionary and also powerful. It was called the Viegnere cipher, after its creator, and it used substitution only in a more complex way. First step to using the algorithm was to create an encryption table of every possible shift alphabet, like so:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
||||||||||||||||||||||||||
A ---- BCDEFGHIJKLMNOPQRSTUVWXYZA
B ---- CDEFGHIJKLMNOPQRSTUVWXYZAB
C ---- DEFGHIJKLMNOPQRSTUVWXYZABC
D ---- EFGHIJKLMNOPQRSTUVWXYZABCD
E ---- FGHIJKLMNOPQRSTUVWXYZABCDE
F ---- GHIJKLMNOPQRSTUVWXYZABCDEF
G ---- HIJKLMNOPQRSTUVWXYZABCDEFG
H ---- IJKLMNOPQRSTUVWXYZAVCDEFGH
I ---- JKLMNOPQRSTUVWXYZABCDEFGHI
J ---- KLMNOPQRSTUVWXYZABCDEFGHIJ
K ---- LMNOPQRSTUVWXYZABCDEFGHIJK
L ---- MNOPQRSTUVWXYZABCDEFGHIJKL
M ---- NOPQRSTUVWXYZABCDEFGHIJKLM
N ---- OPQRSTUVWXYZABCDEFGHIJKLMN
O ---- PQRSTUVWXYZABCDEFGHIJKLMNO
P ---- QRSTUVWXYZABCDEFGHIJKLMNOP
Q ---- RSTUVWXYZABCDEFGHIJKLMNOPQ
R ---- STUVWXYZABCDEFGHIJKLMNOPQR
S ---- TUVWXYZABCDEFGHIJKLMNOPQRS
T ---- UVWXYZABCDEFGHIJKLMNOPQRST
U ---- VWXYZABCDEFGHIJKLMNOPQRSTU
V ---- WXYZABCDEFGHIJKLMNOPQRSTUV
W ---- XYZABCDEFGHIJKLMNOPQRSTUVW
X ---- YZABCDEFGHIJKLMNOPQRSTUVWX
Y ---- ZABCDEFGHIJKLMNOPQRSTUVWXY
Z ---- ABCDEFGHIJKLMNOPQRSTUVWXYZ
Now on first look this may look weird, but it is easier to understand once it is explained. In order to encrypt with this table, you first pick a password. Lets pick CRYPTO as our password and for our message, lets say "HELLO WORLD". Now we can begin encryption, because we both have a key and a message. first things first, find the C row then we can either count over 8 letters since H is the 8th letter in the alphabet or use our top labels and find H and just follow it down the columns until we reach row C. Now we move on to the next letter of our password, which is R. We then look at the second letter in our message E. Now we just follow the E column down until we arrive at row R, and we get our second ciphertext letter X.
Using this method we obtain the letter K. Now we continue to do this for all of our letters until we get the final encrypted message "KXKBI LRJKT". Wow! Will you look at that, multiple letters of Ciphertext can correspond to the same letter. Well this output may look random, there is a way to break it, but it is not easy, and relies heavily on the fact that the password is a word.
One-Time pads
=============
This leads me to my next point which is on the only unbreakable encryption scheme. This scheme is called the one-time pad, and it says that if you have a message that must be kept extremely secret, you generate a truly random key that is the length of the key(by truly random I mean created with a Geiger Counter and some Uranium-225 or other unpredictable unrecreatable means). Because if you encrypt the message with a non-random key it can be broken by attacking the generator. The other catch is that the key(password) must be the same length as the message or else the repetition of the key can be attacked. When this is done, you encrypt with the Viegnere cipher, and the message is
unreadable by anyone but the intended recipient. This is where I bring up another point, you must NEVER, I repeat NEVER, use the same truly random key(password) twice to encrypt different or even the same message, because then when the messages are combined the key is essentially repeated over a longer message, and the messages can be decrypted.
Hiding Ciphertext in Ciphertext & One-time pads
===============================================
There is another very cool aspect of one-time pads, and that is the fact that with truly random key of the same length as the message, you can generate any other message of that length with a few simple formulas:
P + K = C
C - K = P
FK = C + F
C - FK = F
In these equations P stands for the Plaintext(Message), K stands for the Key(Password), C stands for the Ciphertext(Encrypted Message), FK stands for Fake Key(Fake Password), and F is the Fake Message. Now for an example:
K = TBFR
P = MEAN
F = NICE
Now applying the formulas:
C = P + K
C = GGGF
C - K = P
P = MEAN
FK = GGGF + NICE
FK = UPJK
GGGF - UPJK = F
F = NICE
Now that is amazing, because now you can use the same ciphertext and different keys to get different messages.
Well thats it for this time, next time we get into the real cryptography programming, by making a simple XOR Cipher.
--bitshift
This article was originally written by bitshift |