Cryptography Introduction
Cryptography is the technique of securing information by converting it into an unreadable form so that
only authorized users can access and understand it.
Ensures secure communication in the presence of adversaries
Protects sensitive data from unauthorized access
Maintains confidentiality, integrity, authentication, and non-repudiation
Converts plaintext into ciphertext using encryption techniques
Plays a vital role in online transactions, digital security, and data protection
Core Principles of Cryptography
Modern cryptography is built on four fundamental principles:
1. Data Confidentiality
Confidentiality ensures that information is accessible only to authorized individuals or systems. It is
usually enforced through encryption techniques and confidentiality agreements.
2. Data Integrity
Data integrity ensures that information remains accurate, complete, and unchanged throughout its
lifecycle. Any unauthorized modification of data can be detected.
3. Authentication
Authentication verifies the identity of a user or system and confirms that the data being claimed actually
belongs to the sender.
4. Non-Repudiation
Non-repudiation guarantees that a sender cannot deny sending a message or signing a document. It
provides proof of origin and delivery of data.
How Cryptography Works
Consider two parties: Alice (Sender) and Bob (Receiver).
Alice wants to send a secure message m to Bob.
Process Overview
The original message (plaintext) is converted into an unreadable format using an encryption
algorithm and a key k.
The encrypted message is called ciphertext.
The receiver uses the same or a related key to decrypt the ciphertext back into readable form.
Representation
Encryption: C = E(m, k)
Decryption: m = D(C, k)
Where:
m = Plaintext
C = Ciphertext
E = Encryption algorithm
D = Decryption algorithm
k = Key
Example: Caesar Cipher (Shift Cipher)
The Caesar Cipher is one of the simplest encryption techniques. Each letter in the plaintext is shifted by a
fixed number of positions in the alphabet.
Example (Shift = 3):
Plaintext: Geeksforgeeks
Ciphertext: Jhhnvirujhhnv
Even if an adversary knows the encryption method, the message cannot be decrypted without knowing
the key (shift value).
Types of Cryptography
Cryptography can be broadly classified into the following types:
1. Symmetric-Key Cryptography
Uses a single shared key for both encryption and decryption
Fast and efficient
Requires secure key exchange
Example: AES, DES
2. Asymmetric-Key Cryptography
Uses a pair of keys: public key and private key
Public key encrypts data, private key decrypts it
More secure but slower than symmetric cryptography
Example: RSA
3. Hash Functions
Convert data of any size into a fixed-length output
Used to verify data integrity
One-way function (cannot be reversed)
Example: SHA-256
Applications of Cryptography
Cryptography plays a vital role in modern digital systems:
Secure Online Transactions: Protects sensitive data in online banking and e-commerce
Digital Signatures: Verifies authenticity and integrity of digital documents
Password Protection: Encrypts stored passwords to prevent theft
Military and Intelligence: Secures classified information and communication channels
Challenges of Cryptography
Despite its strengths, cryptography faces several challenges:
Key Management: Secure generation, distribution, and storage of keys is difficult
Quantum Computing Threat: Future quantum computers may break current cryptographic
algorithms
Human Error: Weak passwords, poor key handling, and misconfiguration can compromise
security
Cryptography and its Types
Cryptography is the science of protecting information using mathematical techniques to ensure
confidentiality, integrity, and authentication. It transforms readable data into unreadable form,
preventing unauthorized access and tampering.
Converts plaintext into ciphertext using algorithms and keys
Ensures confidentiality, integrity, authentication, and non-repudiation
Used in secure communication, digital signatures, passwords, and online transactions
These algorithms are used for cryptographic key generation, digital signing, and verification to protect
data privacy, web browsing on the internet and to protect confidential transactions such as credit card
and debit card transactions.
Features Of Cryptography
The features of cryptography that makes it a popular choice in various applications could be listed down
as
1. Confidentiality: Information can only be accessed by the person for whom it is intended and no
other person except him can access it.
2. Non-repudiation: The creator/sender of information cannot deny his intention to send
information at a later stage.
3. Integrity: Information cannot be modified in storage or transition between sender and intended
receiver without any addition to information being detected.
4. Adaptability: Cryptography continuously evolves to stay ahead of security threats and
technological advancements.
5. Interoperability: Cryptography allows for secure communication between different systems and
platforms.
6. Authentication: The identities of the sender and receiver are confirmed. As well
destination/origin of the information is confirmed.
Working of Cryptography
As we all know that cryptography technique is use to convert plain text into ciphertext. This technique is
done by cryptographic key. Basically cryptographic key is a string of characters which is used to encrypts
the data and decrypt the data.
Here,
"Hello" is a plaintext and convert into ciphertext "jknnq" with the help of cryptographic key and then
decrypt into "Hello".
Plaintext is created
The original readable message or data.
A cryptographic algorithm is chosen
Example: AES, RSA, SHA-256, etc.
A key is applied
This key controls how the encryption or hashing is performed.
Encryption converts plaintext → ciphertext
The data becomes unreadable to unauthorized users.
Ciphertext is transmitted or stored securely
Even if intercepted, it cannot be understood without the correct key.
Decryption converts ciphertext → plaintext
The receiver uses the correct key (same key for symmetric, different for asymmetric).
Integrity checks may be used
Hashing ensures the message has not been altered.
Types Of Cryptography
There are three types of cryptography, namely Symmetric Key Cryptography, Asymmetric Key
Cryptography and Hash functions, here's a detailed explanation below:
1. Symmetric Key Cryptography
Symmetric Key Cryptography is an encryption system where the sender and receiver of a message use a
single common key to encrypt and decrypt messages.
Symmetric Key cryptography is faster and simpler but the problem is that the sender and
receiver have to somehow exchange keys securely.
The most popular symmetric key cryptography systems are Data Encryption Systems (DES) and
Advanced Encryption Systems (AES).
Example:
Data Encryption Standard (DES)
DES (Data encryption standard) is an older encryption algorithm that is used to convert 64-bit plaintext
data into 48-bit encrypted ciphertext.
It uses symmetric keys (which means same key for encryption and decryption).
It is kind of old by today’s standard but can be used as a basic building block for learning newer
encryption algorithms.
Example of DES Encryption and Decryption tool:
AES (Advanced Encryption Standard):
AES s a popular encryption algorithm which uses the same key for encryption and decryption.
It is a symmetric block cipher algorithm with block size of 128 bits, 192 bits or 256 bits.
AES algorithm is widely regarded as the replacement of DES (Data encryption standard)
algorithm.
2. Hash Functions
Hash functions do not require a key. Instead, they use mathematical algorithms to convert messages
of any arbitrary length into a fixed-length output, known as a hash value or digest.
Hash functions are designed to be one-way, meaning the original input cannot be derived from the
output.
Given Below, Some of the most widely used hash functions include:
SHA-1:
SHA-1 stands for Secure Hash Algorithm 1.
It is a cryptographic hash function developed by the National Security Agency (NSA) and
published by NIST in 1995.
It was designed to ensure data integrity by converting any input into a fixed-size 160-bit (20-
byte) hash value.
SHA-256:
The SHA-256 algorithm belongs to the family of the SHA 2 algorithms.
It generates a fixed 256-bit (32-byte) hash value from input data of any length.
It is widely used in various security applications, including data integrity verification, digital
signatures, blockchain technology, and password hashing, due to its strength and resistance to
known cryptographic attacks.
Example:
Data : geeksforgeeks
SHA256 : f8d59362da74ffe833332dc20508f12de6da6a9298c98b3b42873e7298fced78
MD5:
MD5 produces a 128-bit hash value (32-character hexadecimal number) from input data of any
size.
Originally designed for data integrity verification, MD5 was widely used for checksums, digital
signatures, and file verification.
MD6:
MD6 is a cryptographic hash function designed by Ronald Rivest and his team in 2008 as a
successor to the MD5 and MD4 algorithms.
It was created to be highly secure and suitable for modern computing systems, including multi-
core processors.
3. Asymmetric Key Cryptography
In Asymmetric Key Cryptography a pair of keys is used to encrypt and decrypt information. A sender's
public key is used for encryption and a receiver's private key is used for decryption. Public keys and
Private keys are different. Even if the public key is known by everyone the intended receiver can only
decode it because he holds his private key. The most popular asymmetric key cryptography algorithm
is the RSA algorithm.
Examples:
RSA (Rivest-Shamir-Adleman):
RSA is an basic asymmetric cryptographic algorithm which uses two different keys for encryption. The
RSA algorithm works on a block cipher concept that converts plain text into cipher text and vice versa.
Encryption in RSA
Example:
Choose p = 3 and q = 11
Compute n = p * q = 3 * 11 = 33
This n is part of the public key and also used in both encryption and decryption
Computer Euler's function φ(n)
ϕ(n)=(p−1)(q−1)=(3−1)(11−1)=2×10=20
Choose e such that 1 < e < φ(n) and e and φ (n) are coprime. Let e = 7
Compute a value for d such that (d * e) % φ(n) = 1. One solution is d = 3 [(3 * 7) % 20 = 1]
Public key is (e, n) = (7, 33)
Private key is (d, n) = (3, 33)
Encyption:
Let’s say the message M=4 (must be < n)
Ciphertext C=M^e modn=4^3 mod33=64 mod33=31
Encrypted Message = 31
Decryption:
M=C^d modn=31^7 mod33
Use modular Exponential
31^2 = 961 mod33=4
31^4 = (31^2)^2 = 16
31^7 = 31.31^2.31^4 = 31.4.16 = 1984 mod 33
Now, 1984 mod 33 = 4
Decrypted Message= 4
ECC (Elliptic Curve Cryptography):
lliptic Curve Cryptography (ECC) is a type of asymmetric encryption that provides strong security with
smaller keys than RSA. It’s efficient, fast, and ideal for devices with limited resources like smartphones,
IoT devices, and blockchain wallets. ECC is widely used in secure communications such as TLS/SSL and
cryptocurrencies due to its lightweight yet powerful encryption.
Elliptic Curve
Equation:
We use the standard elliptic curve equation: y^2 = x^3 + ax + b mod p
Let's choose:
Prime field: p =23
Curve parameters: a = 1, b = 1
So the curve becomes: y^2 = x^3 + x + 1 mod 23
Applications of Cryptography
Cryptography has wide area of applications in the modern world, where the technology is rapidly
evolving. These are some of the most common applications of cryptography listed below:
Applications
1. Password Security: Passwords are hashed before storage to prevent exposure even if the database is
leaked.
2. Digital Currencies: Bitcoin and other cryptocurrencies use cryptography for transaction integrity and
identity protection.
3. Secure Web Browsing (HTTPS): SSL/TLS protocols encrypt communication between browser and
server.
4. Electronic Signatures: Legally valid digital signatures created using public-key cryptography.
5. Authentication Systems: Used in bank logins, secure networks, and access control systems.
6. End-to-End Encryption: Messaging apps like WhatsApp and Signal ensure only intended users read
the messages.
Classical Ciphers
Ciphers are methods used to transform readable data (plaintext) into unreadable data (ciphertext) so
that only authorized parties can understand the original content.
Cipher
Examples
Military/Spying - Early secret communication (e.g., Enigma machine)
CTFs / Hack Challenges - Puzzles often hide flags using classical ciphers
Legacy malware - Obfuscates payloads using simple XOR or Caesar ciphers
Categories of Ciphers:
There are mainly two types of Classical Ciphers
1. Substitution Ciphers: Replace characters with other characters using a defined rule
Example:
In Caesar Cipher, A → D, B → E, etc.
Real-Life Use: Simple password obfuscation, CTFs, and puzzle challenges.
2. Transposition Ciphers: Rearrange the order of characters without changing them.
Example:
Rail Fence Cipher, where characters are written in a zigzag and read row by row.
Real-Life Use: Basic message encoding to confuse readers.
Types of Classical Ciphers
There are basic types of Classical Ciphers.
Cipher Name Description Real-life/CTF Use
Each letter is shifted a fixed number of Hidden messages in simple malware,
Caesar Cipher
places. games, or emails.
Vigenère Uses a keyword to shift letters; more Used in older secret messages and CTF
Cipher secure than Caesar. puzzles.
Often seen in basic stego/crypto
Atbash Cipher A → Z, B → Y… Reverses the alphabet.
challenges.
Used in hiding spoilers or light
ROT13 A Caesar Cipher with a shift of 13.
obfuscation online.
Great for simple puzzles and password
Rail Fence A form of transposition cipher that hiding.
Cipher rearranges the order.
Steganography
Steganography is the practice of concealing information. It involves hiding data within an ordinary,
non-secret file or message to prevent detection. The hidden information is being extracted at the
receiving end. Often, steganography is combined with encryption to add an extra layer of security for
the hidden data. With the help of Steganography, we can hide any digital content virtually like text,
image, videotape, etc.
Common Types of Steganography:
Here are the types mentioned below about Steganography
Image Stego (LSB)
Data is hidden in the least significant bits of pixels.
Real-Life Use: Malware communication, CTF challenges.
Text Stego
Secret data hidden using invisible characters, spaces, or misspelled words.
Real-Life Use: Covert communication in censored countries.
Audio Stego
Hidden messages embedded in audio signals, often inaudible.
Real-Life Use: Watermarking or espionage.
Video Stego
Embeds information in video frames or metadata.
Real-Life Use: Covert data exfiltration techniques.
Metadata Stego
Stores data in metadata fields (e.g., EXIF data in images).
Real-Life Use: Hiding payload links in innocent-looking files.