0% found this document useful (0 votes)
25 views2 pages

Cipher Analysis Report

Uploaded by

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

Cipher Analysis Report

Uploaded by

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

Cryptography Cipher Analysis

Report by Ziad Elgizawie | ID: 225271

1. Cipher Analysis

1.1 Keyword and Shifted Alphabet


Cipher analysis often begins with examining the type of cipher used. In substitution ciphers
like Caesar or Vigenère, a keyword or shift value determines how letters in the plaintext are
replaced to form ciphertext. Using a shifted alphabet, each letter in the plaintext is shifted
by a specified amount to produce an encrypted message.

1.2 Encryption Process


The encryption process involves shifting each letter in the plaintext by a fixed amount
determined by the cipher's keyword or shift value. For example, in a Caesar cipher with a
shift of 3, the letter 'A' becomes 'D', 'B' becomes 'E', and so on. This process is repeated for
each letter in the plaintext, resulting in the encrypted ciphertext.

1.3 Example Ciphertext Explanation


For illustration, let’s encrypt the word 'HELLO' with a shift of 3. Applying the shift, we get:

- H -> K
- E -> H
- L -> O
- L -> O
- O -> R

This produces the ciphertext 'KHOOR'. This simple shift method highlights how the shifted
alphabet can be applied to transform plaintext into unreadable ciphertext.

2. Decryption Process

2.1 Reverse the Shift


To decrypt the message, we reverse the shift by shifting each letter in the ciphertext back by
the same amount. Using our previous example of 'KHOOR' and a shift of 3, we reverse each
letter:

- K -> H
- H -> E
- O -> L
- O -> L
- R -> O

This returns the original message, 'HELLO'. Reversing the shift in this manner is the basis of
decryption for substitution ciphers.

2.2 Example with Shifted Alphabet


Using a shifted alphabet for decryption is effective in reversing the encryption process. For
example, if a shifted alphabet is generated with a keyword, it can be applied in reverse to
decrypt the message. This approach is particularly useful in Vigenère and polyalphabetic
ciphers where keywords vary for each letter.

3. Code Snippet
The following Python code snippet demonstrates how to shift an alphabet for encryption
and decryption:

```python
def shift_text(text, shift):
result = ''
for char in text:
if char.isalpha():
shift_base = ord('A') if char.isupper() else ord('a')
result += chr((ord(char) - shift_base + shift) % 26 + shift_base)
else:
result += char
return result

# Encrypt example
plaintext = 'HELLO'
ciphertext = shift_text(plaintext, 3)
print('Encrypted:', ciphertext)

# Decrypt example
decrypted_text = shift_text(ciphertext, -3)
print('Decrypted:', decrypted_text)
```
This code demonstrates a function that shifts each letter in the input text by a specified
number of positions.

You might also like