Unit 3 Part 1 NIS
Unit 3 Part 1 NIS
Explain cryptography -:
Cryptography is the art and science of secure communication in the presence of third parties,
often referred to as adversaries. It involves techniques for encoding information in such a way
that only authorized parties can understand it, while unauthorized parties cannot.
Cryptography plays a vital role in various aspects of modern life, including secure
communication over the internet, data protection, financial transactions, and ensuring the
privacy of sensitive information.
3. Symmetric Cryptography: In symmetric cryptography, the same key is used for both
encryption and decryption. This means that both the sender and the recipient must possess the
same secret key. Popular symmetric encryption algorithms include AES (Advanced Encryption
Standard) and DES (Data Encryption Standard).
5. Hash Functions: Hash functions are cryptographic algorithms that transform input data into
a fixed-size string of bytes, known as a hash value or digest. These functions are used for data
integrity verification, digital signatures, and password hashing. A key characteristic of hash
functions is that they are one-way, meaning it is computationally infeasible to reverse the
process and obtain the original input from the hash value.
6. Digital Signatures: Digital signatures are cryptographic techniques used to verify the
authenticity and integrity of digital messages or documents. They involve using asymmetric
cryptography to create a unique digital signature for a message, which can be verified by
anyone with access to the corresponding public key. Digital signatures provide non-
repudiation, meaning the signer cannot deny their involvement in the message.
7. Key Management: Key management is the process of generating, storing, exchanging, and
revoking cryptographic keys securely. It is crucial for maintaining the security of encrypted
communications and ensuring that keys are only accessible to authorized parties.
Substitution technique
Caesar Cipher -:
The Caesar cipher is one of the simplest and most well-known substitution techniques in
cryptography. It involves shifting each letter of the plaintext by a fixed number of positions
down or up the alphabet.
The Caesar cipher is a basic example of a substitution cipher and is not secure against modern
cryptographic attacks, such as frequency analysis, due to its simplicity. However, it serves as
an educational tool for understanding the concept of encryption through substitution.
working with an example:
Let's say we want to encrypt the plaintext message "HELLO" using a Caesar cipher with a shift
of 3.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
2. Encryption: Shift each letter of the plaintext by three positions to the right (or left).
Plaintext: H E L L O
Ciphertext: K H O O R
In this example, each letter in the plaintext "HELLO" has been shifted three positions down
the alphabet to produce the ciphertext "KHOOR".
To decrypt a message encrypted with the Caesar cipher, you simply shift each letter in the
ciphertext by the same number of positions in the opposite direction.
For example, if we want to decrypt the ciphertext "KHOOR" using the same Caesar cipher with
a shift of 3:
1. Decryption: Shift each letter of the ciphertext three positions to the left (or right).
Ciphertext: K H O O R
Plaintext: H E L L O
A monoalphabetic cipher is a type of substitution cipher where each letter in the plaintext is
consistently replaced with a corresponding letter in the ciphertext. In other words, the same
letter in the plaintext will always be replaced by the same letter in the ciphertext.
This type of cipher is very easy to crack using frequency analysis, where the most commonly
occurring letters in the ciphertext are compared to the frequency distribution of letters in the
language being used (usually English).
Let's say we're using a Caesar cipher with a shift of 3. This means each letter in the plaintext is
shifted three positions to the right in the alphabet.
Plain: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
So, for example, the letter 'A' would be replaced with 'D', 'B' with 'E', 'C' with 'F', and so on.
Plain: H E L L O
Cipher: K H O O R
Decryption is simply the reverse process, where each letter in the ciphertext is shifted back by
3 positions.
Hill Cipher -:
The Hill cipher is a cryptographic algorithm that operates on blocks of text. It's a polygraphic
substitution cipher based on linear algebra. Here's how it works:
1. Key Generation: The first step is to choose a key matrix. This matrix must be invertible
modulo some number, typically the size of the alphabet used (e.g., 26 for the English alphabet).
The size of the matrix determines the block size for encryption and decryption.
2. Encryption: To encrypt a message, you break it into blocks of size equal to the dimensions
of the key matrix. Each block is then treated as a vector and multiplied by the key matrix
modulo the alphabet size. The resulting vector corresponds to the encrypted block.
3. Decryption: Decryption is the reverse process of encryption. You multiply the encrypted
block by the inverse of the key matrix modulo the alphabet size to obtain the original message
block.
Let's say we want to encrypt the message "HELLO" using a 2x2 key matrix:
Polyalphabetic Substitution
One famous example of a polyalphabetic substitution cipher is the Vigenère cipher. In the
Vigenère cipher, a keyword is repeated to match the length of the plaintext. Each letter of the
keyword corresponds to a Caesar cipher shift value. Then, each letter of the plaintext is
shifted according to the corresponding letter in the keyword.
Let's demonstrate the Vigenère cipher with an example:
Suppose we want to encrypt the plaintext "HELLO" using the keyword "KEY".
Keyword: KEYKEY
Plaintext: HELLOH
2. Convert both the plaintext and the keyword into numbers (A=0, B=1, ..., Z=25):
Plaintext: 7 4 11 11 14 7
Keyword: 10 4 24 10 4 24
= 17 8 9 21 18 5
Ciphertext: Q I J V S F
So, the encrypted message for "HELLO" using the keyword "KEY" in the Vigenère cipher is
"QIJVSF".
Transposition technique -:
Transposition ciphers like this offer a different level of security compared to substitution
ciphers, and they're often used in conjunction with other techniques to create stronger
encryption methods.
1. Key Selection: Choose a keyword or phrase that determines the order in which columns are
read during encryption and decryption. For example, the keyword could be "CRYPTO".
2. Matrix Creation: Write the plaintext message into a grid (matrix), filling the cells row by
row. The number of columns should match the length of the keyword. If there are remaining
spaces at the end, fill them with placeholders or ignore them.
Example:
Keyword: CRYPTO
Matrix:
3. Encryption: Read the columns of the matrix in the order specified by the keyword.
Concatenate the characters of each column to create the ciphertext.
Example:
4. Decryption: To decrypt, rearrange the columns of the ciphertext according to the keyword
and then read the rows.
Example:
Ciphertext: "TATHEGISMESASSISECE"
The Rail Fence Cipher is a transposition cipher that rearranges the plaintext by writing it in a
zigzag pattern across multiple "rails" or lines, and then reading off the ciphertext from the
pattern formed by the rails. It's named for its appearance, which resembles a fence with rails.
The Rail Fence Cipher is relatively easy to understand and implement, but it's not very secure
compared to modern encryption methods. It's often used for educational purposes or in
situations where a simple encryption method is sufficient.
1. Key Selection: Choose the number of rails, which determines the pattern of the zigzag.
2. Encryption:
• Write the plaintext in a zigzag pattern across the number of rails chosen.
• Start by writing the first character in the top rail, the second character on the second
rail, and so on, until reaching the bottom rail.
• When reaching the bottom rail, reverse the direction and start moving upwards until
reaching the top rail again.
• Continue this zigzag pattern until all characters are written.
• The ciphertext is formed by reading off the characters from the rails in order from top
to bottom and left to right.
Number of Rails: 3
Zigzag Pattern:
Ciphertext: "HORELWLDO"
3. Decryption:
• To decrypt the ciphertext, recreate the same zigzag pattern with the same number of
rails.
• Write the ciphertext characters in the pattern, filling in the rails from top to bottom
and left to right.
• The plaintext is formed by reading off the characters in a linear fashion from left to
right, following the zigzag pattern.
Zigzag Pattern: