## Cryptography - Encryption and Decryption

Posted on 24th August, 2016 by Hetal Vinchhi

## What is Cryptography? Why to use it?

What is Cryptography? Why to use it? In this era, we are sharing our private data like credit card details, bank information, passwords at many places. So importance of security is highly increased to save us from hackers. Cryptography is process of encryption and decryption of such data, where encryption is scrambling or changing a message to hide it and decryption is the process of unscrambling or changing to make the message more readable.

## How it works?

Let's see how does this work. Let's first look at Caesar Cipher's algorithm.

In this method the message is encrypted based on a number. Suppose the number is 5 and the message is "python". It will be encrypted as given below.

python
1qzuipo
2ravjqp
3sbwkrq
4tcxlsr
5udymts

So the encryption is like: python + 5 = udymts. And following the same way for decryption: udymts - 5 = python.

The above method seems very simple. Every human can decrypt it with few efforts. so lets extend this a bit more. Instead of encrypting it with a single digit. Let's use a stream of numbers. For example, our message is "encryption decryption in python" and the key is 1234. The decryption will occur as given below.

1234123412 3412341234 12 341234
encryption decryption in python
1fodszqujpo efdszqujpo jo qzuipo
2 pet rvk p fg tar kqp  p ra jqp
3  fu  wl   gh  bs  rq    sb  rq
4   v   m    i   t   r     c   r
5fpfvzrwmpp gidtbtukrr jp scujrr

So the decrypted message is fpfvzrwmpp gidtbtukrr jp scujrr. These kind of guess of key is very much harder than the previous one. But it is very easy for our super computers. To prevent such guesses of key, the key must be very much longer and harder (eg. using 256 bits). The harder the key, harder to achive decryption and get the real message.

## Symmetric Encryption Or Private Key Cryptography

In this method the sender and receiver share the same key privately.

## Asymmentric Encryption or Public Key Cryptography

In this method the sender and receiver has common sharable public key to encrypt the message. Both do have a private key to decrypt message.

In the Deffie Hellman's encryption system, each party generates a public and a private key, while they share the public key with everyone.