Tuesday, 22 October 2013

Some exercises with the "Caesar cipher"

The Caesar cipher is an example of character or monographic substitution cipher., as it enciphers by substituting a single (mono) character for other single ones.

in the previous related post, the plaintext gives us :

plaintext to encipher- Arduino to cipher this#
Ciphered_array- Dugxlqr#wr#flskhu#wklv&

* you can use the ascii table link for reference.

The Caesar cipher is named after Julius Caesar, who, according to Suetonius, used it with a shift of three to protect messages of military significance.It is unknown how effective the Caesar cipher was at the time, but it is likely to have been reasonably secure, not least because most of Caesar's enemies would have been illiterate and others would have assumed that the messages were written in an unknown foreign language(1)

Of course we can use other shifts; Hal in Arthur C. Clarke's "2001: A Space Odyssey" was chosen as the name for the computer, as it reads 'IBM' with a forward shift of 25 or a back shift of 1 !! Done in a normal 26 letter-only alphabet characters (basic original form)(2).
*There are other funny facts about Hal, actually: the fact that Kubrick is said to have had problems with the initial  use of IBM logos, who decided to withdraw them, due to their disapproval of a computer killing people and how that would look like for them, in terms of publicity !

Polemics aside...
In cryptography the use of modulus operator is essential. An operation not so easy ( read quick) to do with a calculator I intend to do a whole post on that, as "i love me some maths" !
Not much to say about the Caesar cipher, as most of us tried it as kids at some point. Another widely spread use of it was creating a paper set of double wheels( see below pic).

It is as easy as A becomes D( 3 shifts to the right).

Of course this number of shifts can be increased/decreased, and do all sorts of variations in the enciphering key! 
So an implementation of the Caesar cipher algorithm would have to be described as :

C=(P+s) Mod (Number_of_Characters) 
Number_of_Characters= 26 (also known as keyspace; 26 in the case of low case alphabet only)
 P = numerical equivalent of character plaintext  
 C = Numerical equivalent of ciphertext character
 s = number of shifts/adds 
Ke== Enciphering Key
Kd==Deciphering Key
*The last two are termed the keys of a cryptosystem.
Kerchoffs' principle enunciates that the security of a cryptosystem must not depend on keeping the cryptographic algorithm secret, but only in keeping the KEYS secret.
 Ke= s = 3 ==> (P+s) mod (Number_of_Characters)
 Kd = -s = -3 ==> (C -s)mod (Number_of_Characters)

Check Arduino Implementation post here 

No comments:

Post a Comment

Feel free to contact me with any suggestions, doubts or requests.