0% found this document useful (0 votes)
55 views5 pages

Exp 02

Uploaded by

vanshbohra80422
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views5 pages

Exp 02

Uploaded by

vanshbohra80422
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment No.

2
Aim: Design and implementation of Cesar cipher.
Software Used: Python.
Theory:

Cesar cipher:

The Caesar cipher is a simple encryption technique that was used by Julius Caesar to send secret messages to
his allies. It works by shifting the letters in the plaintext message by a certain number of positions, known as
the “shift” or “key”. The Caesar Cipher technique is one of the earliest and simplest methods of encryption
techniques.

It’s simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter with a fixed
number of positions down the alphabet. For example with a shift of 1, A would be replaced by B, B would
become C, and so on. The method is apparently named after Julius Caesar, who apparently used it to
communicate with his officials.

Cryptography Algorithm for the Caesar Cipher:


 Thus to cipher a given text we need an integer value, known as a shift which indicates the number of
positions each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first transforming the letters into numbers,
according to the scheme, A = 0, B = 1,…, Z = 25. Encryption of a letter by a shift n can be described
mathematically as.
 For example, if the shift is 3, then the letter A would be replaced by the letter D, B would become E, C
would become F, and so on. The alphabet is wrapped around so that after Z, it starts back at A.
 Here is an example of how to use the Caesar cipher to encrypt the message “HELLO” with a shift of
3:

1. Write down the plaintext message: HELLO


2. Choose a shift value. In this case, we will use a shift of 3.
3. Replace each letter in the plaintext message with the letter that is three positions to the right in the
alphabet
4. The encrypted message is now “KHOOR”.

 To decrypt the message, you simply need to shift each letter back by the same number of positions. In
this case, you would shift each letter in “KHOOR” back by 3 positions to get the original message,
“HELLO”.

Algorithm for Caesar Cipher

Input:

1. Choose a shift value between 1 and 25.


2. Write down the alphabet in order from A to Z.
3. Create a new alphabet by shifting each letter of the original alphabet by the shift value. For example, if
the shift value is 3, the new alphabet would be:
4. 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
DEFGHIJKLMNOPQRSTUVWXYZABC
5. Replace each letter of the message with the corresponding letter from the new alphabet. For example, if
the shift value is 3, the word “hello” would become “khoor”.
6. To decrypt the message, shift each letter back by the same amount. For example, if the shift value is 3, the
encrypted message “khoor” would become “hello”.

Procedure:
 Traverse the given text one character at a time.
 For each character, transform the given character as per the rule, depending on whether we’re encrypting
or decrypting the text.
 Return the new string generated.
Features of Caesar Cipher
1. Substitution cipher: The Caesar cipher is a type of substitution cipher, where each letter in the plaintext
is replaced by a letter some fixed number of positions down the alphabet.

2. Fixed key: The Caesar cipher uses a fixed key, which is the number of positions by which the letters are
shifted. This key is known to both the sender and the receiver.

3. Symmetric encryption: The Caesar cipher is a symmetric encryption technique, meaning that the same
key is used for both encryption and decryption.

4. Limited key space: The Caesar cipher has a very limited key space of only 26 possible keys, as there are
only 26 letters in the English alphabet.

5. Vulnerable to brute force attacks: The Caesar cipher is vulnerable to brute force attacks, as there are
only 26 possible keys to try.

6. Easy to implement: The Caesar cipher is very easy to implement and requires only simple arithmetic
operations, making it a popular choice for simple encryption tasks.

Advantages
 Easy to implement and use thus, making suitable for beginners to learn about encryption.
 Can be physically implemented, such as with a set of rotating disks or a set of cards, known as a scytale,
which can be useful in certain situations.
 Requires only a small set of pre-shared information.
 Can be modified easily to create a more secure variant, such as by using a multiple shift values or
keywords.

Disadvantages
 It is not secure against modern decryption methods.
 Vulnerable to known-plaintext attacks, where an attacker has access to both the encrypted and
unencrypted versions of the same messages.
 The small number of possible keys means that an attacker can easily try all possible keys until the correct
one is found, making it vulnerable to a brute force attack.
 It is not suitable for long text encryption as it would be easy to crack.
 It is not suitable for secure communication as it is easily broken.
 Does not provide confidentiality, integrity, and authenticity in a message.
Input:

Output

Conclusion: Thus, I successfully studied and implemented the Caesar cipher cryptography technique, gaining
hands-on experience with both encryption and decryption processes. By shifting letters of the alphabet based on
a chosen key, I was able to effectively encode and decode messages.

You might also like