strangerRidingCaml

2. Classical Cryptography 본문

Modern cryptography

2. Classical Cryptography

woddlwoddl 2024. 5. 6. 16:16
728x90
Classical Cryptography

Classical Cryptography

Classical Ciphers

  • Caesar cipher: A simple substitution cipher where each letter in the plaintext is shifted by a fixed number of positions.
  • Vigenère cipher: A polyalphabetic substitution cipher using a keyword to shift letters in the plaintext.

Cryptanalysis Techniques

  • Frequency analysis: Analyzing the frequency of letters or symbols in the ciphertext to deduce patterns and break the cipher.
  • Brute force attacks: Exhaustively trying all possible keys until the correct one is found.

Overview of Classical Cryptosystems

  • Enigma: A rotor-based electromechanical cipher machine used by the Germans during WWII, notorious for its complexity and initial unbreakability.
  • RSA: An asymmetric cryptosystem widely used for secure communication and digital signatures, based on the difficulty of factoring large prime numbers.

Laboratory Activities

Lab 1: Caesar Cipher Encryption and Decryption in Python


def caesar_cipher(text, shift):
    result = ""
    for char in text:
        if char.isalpha():
            shift_amount = shift % 26
            if char.islower():
                shifted_char = chr((ord(char) - ord('a') + shift_amount) % 26 + ord('a'))
            else:
                shifted_char = chr((ord(char) - ord('A') + shift_amount) % 26 + ord('A'))
            result += shifted_char
        else:
            result += char
    return result

plaintext = "Hello World"
shift = 3
ciphertext = caesar_cipher(plaintext, shift)
print("Plaintext:", plaintext)
print("Ciphertext:", ciphertext)

This lab demonstrates the encryption and decryption of text using the Caesar cipher algorithm in Python.

Lab 2: Frequency Analysis in Python


from collections import Counter

def frequency_analysis(ciphertext):
    frequencies = Counter(ciphertext)
    sorted_frequencies = sorted(frequencies.items(), key=lambda x: x[1], reverse=True)
    return sorted_frequencies

ciphertext = "Zk Zjxyk Zk Zkizxxz"
print("Ciphertext:", ciphertext)
print("Frequency Analysis:", frequency_analysis(ciphertext))

This lab illustrates frequency analysis on a given ciphertext to identify potential patterns and decipher the message.

'Modern cryptography' 카테고리의 다른 글

6. Cryptographic Protocols  (0) 2024.05.06
5. Hash Functions and Digital Signatures  (0) 2024.05.06
4. Public-Key Cryptography  (0) 2024.05.06
3. Symmetric Cryptography  (0) 2024.05.06
1. Introduction to Cryptography  (0) 2024.05.06