Assignment 4 E21cseu0021
Assignment 4 E21cseu0021
Sachchit Bhasin
E21CSEU0021
Q1. The intercepted message is: "Jxu qtkx tqtu xqqd ymj wtrjx, ywi xjhwjwymj nxj xntsx tsxtr ymj
xfsyjw nx tsqxywtrjx. Qd uqfd wtr ymnx nsxjw tk ymj uqfd tk jyflqnx, ymj xfsyjw nxj ymj uqfd tk mjfy
qnuux. Qnuux tzw qjiytz!" • Using your without knowledge of the key, try to find the actual message.
• Specify the values of 'a' and 'b' that you used for decryption.
Ans. The intercepted message appears to be encrypted using a simple Caesar cipher, which is a type
of substitution cipher where each letter in the plaintext is shifted a certain number of places down or
up the alphabet. In the case of the Caesar cipher, the shift is uniform for all letters.
The decryption of a Caesar cipher requires knowing the shift value. However, if the shift value is not
known, one common approach is to use frequency analysis or brute force to try all possible shifts (in
English, this would be 25 possible shifts as there are 26 letters in the alphabet).
Unfortunately, without knowing the shift value (the ‘a’ and ‘b’ you mentioned), it’s not possible for
me to decrypt the message directly. However, I can show you how to perform a brute force
decryption in Python:
Q2. Implement the Affine Cipher in a programming language of your choice, emphasizing the
numerical operations involved.
Ans.
Q3. Create a user interface for decrypting messages using the Affine Cipher. Allow users to input the
encrypted message and the decryption key.
Ans.
Q4. Discuss the strengths and threats against of the Affine Cipher based on the numerical aspects.
Reflect on how the numerical parameters 'a' and 'b' affect the encryption and decryption processes
Ans. The Affine Cipher is a type of monoalphabetic substitution cipher where each letter in an
alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and
converted back to a letter. The encryption function for a single letter is:
E(x)=(ax+b)mod m
where:
D(x)=a−1(x−b)mod m
1. Simplicity: The Affine Cipher is simple to understand and implement, which makes it a good
starting point for learning about cryptography.
2. Larger key space: Compared to the Caesar cipher, which is a special case of the Affine cipher
with a=1, the Affine cipher has a larger key space. This means there are more possible keys
that can be used for encryption, which can make the cipher more secure against brute force
attacks.
1. Vulnerable to frequency analysis: Like all substitution ciphers, the Affine Cipher is vulnerable
to frequency analysis. This is because the cipher preserves the frequency of each letter in the
plaintext. For example, in English text, the letter ‘E’ is the most common. So, if ‘E’ is
encrypted as ‘X’, then ‘X’ will be the most common letter in the cipher text.
2. Small key space: Despite having a larger key space than the Caesar cipher, the key space of
the Affine cipher is still relatively small, making it vulnerable to brute force attacks. There are
only 312 possible keys for the Affine cipher in English (a must be chosen from the set of
coprime numbers with 26, which has 12 elements, and b can be any number from 0 to 25).
The value of ‘a’ must be chosen such that ‘a’ and ‘m’ are coprime. This is necessary so that ‘a’
has a multiplicative inverse mod ‘m’, which is needed for the decryption process.
The value of ‘b’ determines the “shift” applied to the plaintext. Different values of ‘b’ will
result in different ciphertexts for the same plaintext.
Together, ‘a’ and ‘b’ form the encryption key for the Affine cipher. Changing either ‘a’ or ‘b’
will result in a completely different ciphertext for the same plaintext. This means that the
security of the Affine cipher relies on keeping both ‘a’ and ‘b’ secret. If either ‘a’ or ‘b’ is
known to an attacker, it becomes much easier to break the cipher.
In conclusion, while the Affine Cipher is a step up from the Caesar cipher in terms of complexity and
key space, it is still a relatively weak cipher by modern standards and is not suitable for securing
sensitive information. It is, however, a good cipher for educational purposes, demonstrating the
principles of substitution and the importance of key space in cryptographic security.
Q5. Provide examples illustrating how increasing the key space enhances security
Ans. Increasing the key space enhances security by making it more difficult for an attacker to
guess the key through a brute force attack. A brute force attack involves trying all possible
keys until the correct one is found. The larger the key space, the more possible keys there are
to try, and the longer a brute force attack will take.
1. Caesar Cipher vs Affine Cipher: The Caesar Cipher is a type of substitution cipher
with a key space of size 26 (for English alphabet). This means there are 26 possible
keys that can be used for encryption. On the other hand, the Affine Cipher, which is a
generalization of the Caesar Cipher, has a key space of size 312 (for English
alphabet). This is because there are 12 possible values for ‘a’ (numbers coprime with
26) and 26 possible values for ‘b’. Therefore, the Affine Cipher is more secure than
the Caesar Cipher because it has a larger key space.
2. DES vs AES: The Data Encryption Standard (DES) uses a 56-bit key, which means it
has a key space of size 256. This was considered secure when DES was first
introduced, but with the increase in computational power, it became feasible to try all
possible keys, making DES insecure. The Advanced Encryption Standard (AES),
which is now widely used, has a larger key space. It supports key sizes of 128, 192,
and 256 bits, with the largest key size giving a key space of size 2256. This is
considered secure against brute force attacks with current technology.
3. RSA: RSA is a public-key encryption algorithm that uses two keys: a public key for
encryption and a private key for decryption. The security of RSA depends on the
difficulty of factoring large numbers. If small key sizes are used, it is possible to
factor the keys with enough computational resources. However, as the key size
increases, factoring becomes infeasible. Today, a key size of 2048 bits is commonly
used, which is considered secure.
In all these examples, increasing the key space enhances security by making brute force
attacks more difficult. However, it’s important to note that increasing the key space also
increases the computational requirements for encryption and decryption. Therefore, a balance
needs to be struck between security and performance.