# Cryptography Basics | Definition With Examples

The fundamental objective of cryptography is to enable two people to communicate in a secure way over a public channel. Cryptography is also called the art and science of secret writing.

## Cryptography Basics

Let’s understand the basic concept of cryptography with an example. Here in the above figure, there are two people Alice and Bob.

Alice wants to send his age to Bob. If He sends his age directly to Bob over a public channel(insecure), then other guys who can also access the data transferring between Alice and Bob. The bad guy can change the data(age) too before reaching to Bob.

 Cryptography Basics with Example

To overcome this problem, the concept of cryptography introduced. In this system, data transfer from one point to another point in encrypted form. Therefore, it is difficult to decrypt the data in the middle.

## Cryptography Example in Detail

Again look at the figure. In this figure, Alice wants to send his age to Bob. Let's consider Alice's age is 24, here the 24 is called Plaintext. The plaintext is the original message that a sender wants to send.

Now Alice adds a random number 42 to the 24. Here 42 is the Key. The key is the secret word or number known to communicators only. In this case, Alice and Bob are using the key 42.

After the addition, a new number 66 is generated by the encryption process. The encrypted message is known as Ciphertext. Here 66 is the ciphertext. And Encryption is the process that converts plaintext to ciphertext. The middle guy only can access ciphertext.

When Bob receives the ciphertext, he uses the same key(42) to decrypt the ciphertext. Bob subtracts 42 from the ciphertext and gets Alice's age. Decryption is the process that converts ciphertext to plaintext.

Thus, cryptography works to make the communication secure between two people over the public channel.

## Cryptography Types

There are two types of cryptography as following.

### Symmetric or Secret key cryptography

The example discussed above works on symmetric-key cryptography. In this type of cryptosystem, both parties share the same secret key or single key.

### Asymmetric or public-key cryptography

In this type of cryptosystem, both the party have two pairs of keys.

## Cryptography Definition Formally

Cryptosystem have generally five tuples i.e. (P, C, K, E, D) where

P: Set of all possible plaintext.
C: Set of all possible ciphertexts.
K: Set of all possible keys.
E: Set of all possible encryption algorithms. i.e. e: P × K → C then eₖ(m) = c
D: Set of all possible decryption algorithms. i.e. d: C × K → P then dₖ(c) = m iff eₖ(m) = c

Definition:For every k ∈ K, Ǝ an eₖ∈E and dₖ∈D such that dₖ(eₖ(m)) = m ∀ m∈P, where eₖ, dₖ should be computationally feasible.