# Cryptography Concepts Explained

## Let's understand the cryptography which is extensively used to protect your sensitive data across the web.

Nowadays, cryptography is widely used to protect sensitive data that travel across the internet. The 's' in 'https' stands for secure. It means that cryptography is being used to guarantee that the website you are visiting is genuine. Blockchains are not generally encrypted but cryptography is extensively used in blockchains protocol. Encryption means converting plain text into cypher text (A jumble of meaningless text that uses excessive technical terms), so snoopers cannot understand that. On the other hand, decryption means converting a cypher text into human-readable meaningful text.

Let's take an example: Person A wants to send a message to person B so that only person B can read it. They agreed with an encryption rule of +1. If A sends "HELLO", then the message will be encrypted by shifting each letter by 1 ahead. Hence after encryption, it will be "IFMMP". Here, 'H' becomes 'I', 'E' becomes 'F', 'L' becomes 'M' and 'O' becomes 'P'. When B wants to read it, he knows the decryption method, he will shift all the letters backwards at one time and can get the actual form of text. This process is known as '**Symmetric Caeser Cypher**'.

But the problem is in the real world where technology is constantly changing day by day. The use of a Symmetric scheme might be harmful because anyone who knows the process, can easily decrypt and snoop on the data.

**Public-key cryptography** is an asymmetric scheme where the key used to encrypt and the key used to decrypt the data are not the same. It uses two different keys in pair: a public key and private key. You can share your public key with the world. Hackers will not be able to extract your private key from your public key. If anyone sends a message to your public key, it can only be decrypted by the private key, known to you. Public key cryptography is a huge improvement after the symmetric data encryption scheme.

**Digital Signature:**: A paper signature can be copied easily. If you sign a cheque or document, your signature always looks the same. It may put you at risk. Digital signatures are widely used in Bitcoin and blockchain. It is a mathematical technique that is used to validate your data. A digital signature can be generated by applying some mathematical rules using the private key with your data. You can generate the digital signature after some mathematical steps. But It is not possible to back-calculate from a digital signature easily.

Let's take an example: I have created a small message "Good Morning" and want to sign in it digitally using the SHA-256 algorithm. If you are using Linux or Mac, you can encrypt that message by using the following command.

```
echo "Good Morning" | sha256sum
```

It generates a cryptographic hash.

```
99e3364342c32c906d8da21741999e5517a19ed270e4452489474ec1d4b01bf3 -
```

If I make a slight change in my message from "Good Morning" to "Good Morning!". It will generate another hash which is totally different from the previous one. A small change made in the message will change the entire hash output.

```
abda17dc316047a7898e55e600341abf59b71fb6d4993189c760e1ec0b587e3c -
```

So, you cannot guess the actual changes made in the message by looking at these two hash. Any tampering on the hash will make the digital signature invalid. No one in the world except you will be able to decrypt the digital signature unless they have your private key. That's why all the middlemen or third-party mediums are eliminated from blockchain and asymmetric cryptography is widely used in blockchain transactions.

#thw-web3