26332 total geeks with 3498 solutions
Recent challengers:
  • krc bonus 5 - 12:32PM
  • krc bonus 23 - 11:03AM
  • krc bonus 12 - 08:08AM
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

Donate
Donate and help us fund new challenges
Donate!
Due Date: Jun 30
June Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
BT boss QUITS
telecoms giant for
front-bench gov job
NASA probe eases
through Saturn"s
ring to grab Earth
snapshot
Ex-Systemax veep
cuffed, charged
with $230m fraud
Roving IT
contractors and
private landlords
are my heroes -
here"s why
Wi-Fi Alliance
takes grid place,
revs engine in race
to 802.11ac
Julian Assange: I"m
quite happy to
sleep on Ecuador"s
sofa FOREVER
Supercomputer sage
Cray musters Lustre
cluster storage
hustler
Sneaky Seagate
slips "world"s
fastest" enterprise
disk mutant into
the wild
Hey mobile firms:
About that Android
thing... Did Google
add a lockout
clause?
PC makers REALLY
need Windows 8.1 to
walk on water - but
guess what?
Slashdot
Lobster, a New Game
Programming
Language, Now
Available As Open
Source
Google"s Crazy Lack
of Focus: Is It
Really Serious
About Enterprise?
Cat-like Robot Runs
Like the Wind
Revisiting Amdahl"s
Law
Altering Text In
eBooks To Track
Pirates
NVIDIA To License
Its GPU Tech
MySQL Man Pages
Silently Relicensed
Away From GPL
Verizon Accused of
Intentionally
Slowing Netflix
Video Streaming
Oculus Rift Raises
Another $16 Million
KWin Maintainer:
Fanboys and Trolls
Are the Cancer
Killing Free
Software
Article viewer

Introduction to Cryptography Part 2



Written by:dimport
Published by:CodeX
Published on:2003-06-21 07:19:46
Topic:C++
Search OSI about C++.More articles by dimport.
 viewed 7291 times send this article printer friendly

Digg this!
    Rate this article :
Welcome back, hopefully you read my last tutorial, because it will give you a little more background for working with this tutorial. Well, lets get started.

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

Did you like this article? There are hundreds more.

Comments:
<none>
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
harry
Blog entry for Thu 28th Sep 12pm on Thu 28th Sep 12pm
Hi In school i want to net send my mates but hide who its coming off any ideas. no programs though as the machine in school sets off an alarm if it detects any batch files etc... thanks Harry


     
Your Ad Here
 
Copyright Open Source Institute, 2006