Saturday 2 May 2020


Cryptography



The word Cryptography comes from the Greek word kryptos which means hidden, secret.

Kryptos + Graphy  = hidden +writing 

The earliest known use of cryptography is found in non-standard hieroglyphs carved into the wall of a tomb from the Old Kingdom of Egypt circa 1900 BC.
Later we saw the use of Cryptography in World War- 1 and World War -2, at this time Army were using Cryptography machines for Cryptography, Enigma machine is a good example of a machine used by German for Cryptography in Second World War.


Image of Enigma machine

Lets understand cryptography with an example. We will take a message and we will encrypt it.

 example 1:

My  name is Rahul
We will encrypt above line like this:
Rd sfrj nxwzq

By reading the above line(Rd sfrj nxwzq ) no one can understands what is written here, until he has the key to decrypt it into plain text, here we used key= 5, if anyone know that all text is change here by 5 latter ahead in English alphabet from its original latter, then that can change it again to the plane text,

Before moving ahead we need to understand few important terms like plain text and cipher text, key etc.

Plain Text:

Plain text are the text that can be read directly by human and can understand easily. This is the input data for Encryption process, here in the above example 1 plain text is:
My  name is Rahul.

Ciphertext:


Ciphertext are not human understandable text. In cryptography, cipher text is the result of some operation performed on plaintext using an algorithm.  
In example 1. Cipher text is  
Rd sfrj nxwzq

Cipher:

In cryptography, a cipher (or cypher) is an algorithm for performing encryption. Ex. ASE, DES

Key:

In cryptography, a key is a piece of information that determines the functional output of a cryptographic algorithm. For encryption algorithms, a key specifies the transformation of plaintext into ciphertext, and vice versa for decryption algorithms.
In the above example 1 Key is 5

Before we move ahead we need to understand two more important terms.

Stream Cipher and Block Cipher

Stream Cipher:


Stream Cipher is a technique used to encrypt plain text to cipher text and vise versa. It encrypt or decrypt text bit by bit, means at each bit it take action. It performs operation by XOR and It uses substitution technique for it.
In Simple words we can understand it in such a ways that to decrypt a plain text, first we need  to convert plan text in binary form then we apply encryption technique on each bit. It is called Stream Cipher.



We will take another example to understand it in better way.
Take a Plain text 9
Key is 8
Convert both in Binary form:


Digit
Binary Number
9 (Plain Text)
1001
8 (Key)
1000

Now we will perform XOR operation and the result is: 0001
So 0001 is our cipher text. And if we will convert in decimal form it is 1. Now we have
 plain text is 9
Cipher text is 1
Key is 8
So like this be Encrypt the plan text into cipher text bit by bit.

Block Cipher

This is a method of encryption in which plain text is divided into small blocks and encryption algorithm is used on each block to get cipher text. We use same key on each block for encryption.  The size of block depends on the types of algorithm we use.





There are several modes of operations for a block cipher.
Electronic Code Book
Cipher Block Chaining
Cipher Feedback Mode
Output Feedback Mode
Counter Mode

Purpose of Encryption:

This is a very good technique to send text message securely. These days Cryptography is more popular and used everywhere. We use Cryptography for Confidentiality, Authentication, Integrity, Non-repudiation.


Confidentiality: Ensuring that no one can read the message except the receiver

Authentication: Authentication means  the process or action of proving or showing something to be true, genuine, or valid, so with the help of cryptography we ensure that message should be received by authenticate person. We ensure it with the help of keys used by sender and receiver.

 Integrity: the quality of being honest and having strong moral principles, with the help of encryption we ensure that the message that we are sending should not alter or change so that receiver should get the same messages that sender send for him.

Non-repudiation: Imagine a situation where a statement's author cannot successfully dispute its authorship or the validity of an associated contract, so cryptography is used to prove that the sender really sent this message.


Now a day’s Cryptography is very common and it is used at many place while communication. when we email, when we text message from application like whats app ( Whats app user End to End Encryption (Asymmetric Encryption) technology which secure you text as well as voice conversation over network).Encryption is used in storage media to store information.  There are few popular algorithm that is used  for it, few very command cryptography algorithm are “Pretty Good Privacy (PGP)”  Phil Zimmermann developed PGP in 1991, Data encryption standard (DES) designed by IBM in 1975, RC4 (Rivest Cipher 4) designed by Ron Rivest in 1994., Advanced Encryption Standard (AES)designed by Vincent RijmenJoan Daemen in 1998 and much more, I will explain few of it in my future blogs.


There are three  cryptographic techniques: 

1. Symmetric-key cryptography
2. Public-key cryptography
3. Hash functions.

1. Symmetric-key cryptography

Symmetric encryption is a type of encryption where only one key (a secret key) is used to both encrypt and decrypt electronic information. Ex. AES

2. Public-key cryptography

Public-key cryptography is a form of Encryption where keys come in pairs. one key is Public used to Encrypt the plan text and other private key is used to decrypt the cipher test. RSA Encryption.


3. Hash functions.:


 A hash function is any function that can be used to map data of arbitrary size to fixed-size values. This function convert data into a fix size code, and if we modify data the value of hash also get change. Few popular hash algorithms are: MD5, SHA1, SHA256.



Ex. String 1 : Your String: My name is rahul
MD5 hash of string 1: 1f34ce0cd2ee72cc2dfd91d51cb9a3ee

If we will modify string 1 like string 2.

String 2: my name is rahul

MD5 hash for string 2: 4c32f8e4531f049c04e92b4ce4d89ce7

Here we just changed M (Upper case) from My in string 1 into m (Lower case) in string 2, as a result value of MD5 hash for string 2 get changed.

Why we use hash algorithm ?

Suppose there are two files and you want to check both files are same or not, so to do that its really difficult to check each line of the file, so we can covert that into Hash value. If both file have same hash value it means both are same files.

No comments:

Post a Comment