My blog audience

Diberdayakan oleh Blogger.
RSS

Classical Cryptography Algorithms (& Caesar Code)

Cryptography has been used since four centuries ago. The development of cryptography is so fast until now. To get a sense of how a cryptographic algorithm developed, following the explanation below will browse one at a classical algorithm, the technique of substitution and transposition techniques.

Classical cryptography has several characteristics: 
  1. Based Character, 
  2. Using pen and paper only, no computer, 
  3. included into the key cryptography symmetry.

Three reasons for studying the classical cryptography: 
  1. Understand the basic concepts of cryptography. 
  2. Modern basic algorithm. 
  3. Understand the weaknesses of the system code.

Substitution Technique
Substitution is the replacement of each character-original text with other characters.



There are four terms of code, among others:
  • Monoalphabet: Every character-coded text characters replace one of the original text.
  • Polyalphabet: Every character-coded text to replace more than one kind of character-the original text.
  • Monograph: The encryption performed on the original single-character text.
  • Polygraph: The encryption performed on more than one character-the original text.


Caesar Code
Substitution of the first in the world of encryption (coding) occurred during the rule of Julius Caesar, known as Emperor's code, using the initial letters of the alphabet position or also called ROT3 algorithm.
Caesar Cipher (ROT3)


In more detail, consider the following example:


Be:


If the shift is performed three times then the key for decryption is 3. Shift key by sending a message depends on the will. It could be the key that is used a = 7, b = 9, and so on.

Sample code algorithm Cesar: For the original text-provided symbol "P" and the text-code "C" and key "K". So the formula can be made as follows:
C = E (P) = (P + K) mod (26)

In the example above, we can put the key with a value of three so that it becomes:

C = E (P) = (P +3) mod (26)

Decryption formula like the following:

P = D (C) = (C-K) mod (26)

From the example above, by entering a key three, then:
P = D (C) = (C-3) mod (26)

If given the original text as follows:

Jika diberikan teks-asli sebagai berikut:

GEMPA YOGYA MENELAN KORBAN TIDAK SEDIKIT DAN SAMPAI SEKARANG MASIH MENYISAKAN TRAUMA BAGI ORANG-ORANG KOTA GUDEG
Dengan menggunakan kunci tiga, maka akan didapat teks-kode berikut:
JHPDBRJBDPHQHODQNRUEDQWLGDNVHGLNLWGDQVDPSDLVHNDUDQJPNHDUDQJPHQBLVDNDQWUDPDEDJLRUDQJRUDQJNRWDJXGHJ

Code Emperor resolved by brute force attact, a form of attacks carried out by trial and error to find the key possibilities. Can also use the exhaustive key search, because the number of keys is very small (only have 26 keys). Although few, key a bit tedious code kriptanalis (people who break the code), because to find it by brute force attact it takes a long time.

There are other ways that can be used kriptanalis to solve, namely by looking at the frequency of occurrence of the letters as shown by the appearance frequency table the following letter:



Brute force attact also used to find the password and ID of a system. In this attack the attacker tried a few possibilities that exist from the list of words in the dictionary. Generally, this attack can succeed, just take a long time.
Listing program to decrypt the files using the code Emperor:

/ * Program decrypt files using the Caesar cipher * /
# Include
main (int argo, char * argv [])
{
File * Fin, * Fout;
char p, c,
int n, i, k;

Fin = Open (argv [1], "rb");
If (fin == NULL)
printf ("Error in opening file% s as input / n", argv [1]);
Fout = fopen (argv [2], "wb";
printf ("\ nDekripsi% s to% s... \ n", argv [1], argv [2]);
printf ("\ n");
printf ("k:");
scanf ("% d", & k);
while ((c = getc (fin))! = EOF)
}
P = (c - k)% 256;
Putc (p, Fout);
}
fclose (Fin);
fclose (Fout);
}

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Posting Komentar