Cryptography Basics With Examples

Learn cryptography basics with detailed real-world example. Types of cryptography, and its formal definition discussed.

Cryptography basics with example

The fundamental objective of cryptography is to enable two people to communicate securely 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 can also access the data transfer between Alice and Bob. The bad guy can change the data(age) too before reaching Bob.

Cryptography basics example
Cryptography Basics with Example

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

Cryptography Example

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. 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 communication secure between two people over the public channel.

Cryptography Types

There are two types of cryptography as follows.

  1. 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.
  2. Asymmetric or public-key cryptography In this type of cryptosystem, both parties have two pairs of keys.

Formal Definition of Cryptography

Cryptosystems 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.