# Basic of Cryptography | Hacker Noon

tech enthusiast. love computers , programming and hacking.

Hi everyone this is Gurdeep , in this i am gonna talk about what is cryptography? and discuss some ancient crypto system.

So what is cryptography??

In Today's world almost every educated person might heard the word
cryptography. Some of you already know what it is but those who don't know , Cryptography is science of hiding meaning of information from non intended user or It is a practice of making communication more secure. Communication can be between humans, machines, or humans  and machines.

For example :

There are 2 humans Alex and Bob living 1000 kms away for each other. Alex want to send some secret message to Bob, so he writes a letter to Bob and send it through post-office. But the postman of that office is sneaky guy and before handing the letter to Bob he opened up the letter and read the secret and paste it as it was before not letting Bob know that letter was already read and it is not a secret anymore.

This led to a fundamental problem in communication. How to make it secure so that only intended person can read the message. As it is related to communication it is more fundamental than you think. Even in ancient times King want to send his message to knight more securely as if enemy read those message it might cause big trouble.So the thoughts and research in cryptography has very long history. Many great minds worked on this problem.

One of the most famous ancient crypto-system is Ceaser's Cipher created by Julius Ceaser. It is a very basic crypto system. Suppose Alex and Bob are working in English language and Alex want to send message "this is my secret" to Bob. He knows  that the sneaky postman will read the message if send as plain text So they decided that all letters will be send after encrypted by Ceaser's cipher.

What Alex will do is first he chose a Key, a number between 1-26 as there are 26 alphabet in English. Let the Key he chose was 10. Now for each letter in message he will shift it by key. i.e

A ---> K

B ---> L

C ---> M

D ---> N

E ---> O

...

P ---> Z

Q ---> A

...

Z ---> J

So the message "this is my secret" will become "drsc sc wi combod" after the shift. Now if postman read the message he would see "drsc sc wi combod" which didn't make any sense for him and he would not find the secret.

This is a nice solution. one of the problem with Ceaser's Cipher is that key is limited to size of alphabet set i.e 26 for English. If postman know it's a Ceaser's cipher it only take at most 26 tries to guess the correct key and reveal the secret.

So it needed improvement. One way to improve this is , instead of using a number as a key, just map each letter randomly to other letter and use
that sequence as key. What i mean is ....

ABCDEFGHIJKLMNOPQRSTUVWZYZ can be mapped to
QWERTYUIOPASDFGHJKLZXCVBNM and this sequence become the key.

So each A in plain message will become Q , B --> W and so on. So the message "this is my secret" will become "ziol ol dn ltektz". As there are 26 alphabet so mapping can be done in 26! ways so postman has to try 403291461126605635584000000 this much combination. This is quite good improvement over basic Ceaser Shift and it is known as substitution cipher. However there is a way to decode message encypted by substitution in reasonable time. This technique of cracking substitution cipher is known as frequency analysis.

As in mono-alphabetic substitution cipher , one letter is mapped to only one other letter. Now what postman can do is , he save all encrypted message in his notebook and when he save some hundreds of words in his notebook then can calculate the frequency of each letter in cipher texts and arrange them in Descending order. Suppose after doing this he get

sequence....