Skip to content

A Python-based collection of classical cryptographic algorithms and number theory utilities designed for educational purposes.

Notifications You must be signed in to change notification settings

Wiiifiii/Classical-Cryptography-Theory-in-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔐 Classical Cryptography & Number Theory in Python

This project includes Python implementations of several classical cryptographic algorithms and number theory utilities. The scripts demonstrate encryption techniques (like the Caesar and Vigenère ciphers), number theoretic functions (like GCD and Euler’s Totient), and basic cryptanalysis using the chi-square test.


📁 File Descriptions

🛡️ Cryptographic Algorithms

  • Caesar-Cipher-Algorithm.py
    Implements Caesar cipher encryption by shifting characters by a fixed key. It supports preserving punctuation and letter casing.

  • Vigenere-Cipher-Algorithm.py
    Implements the Vigenère cipher using a keyword. Includes both encryption and decryption functions. Supports an extended alphabet (e.g., ÅÄÖ).

  • Chi-Square.py
    Performs frequency analysis on Caesar-ciphered text using the chi-square test to detect the most likely shift key for decryption.


🔢 Number Theory Utilities

  • CoPrime.py
    Finds a number e that is coprime with both N and T using Python’s math.gcd() function.

  • Euler's-Totient.py
    Computes Euler’s Totient Function φ(n) for various integers, useful for RSA key generation and number theory analysis.

  • Greatest-Common-Divisor-GCD.py
    Implements the Euclidean algorithm to calculate the greatest common divisor of two numbers.

  • Prime-Factors.py
    Calculates all prime factors of a given integer (or list of integers) using trial division.


🧠 Algorithmic Problem

  • SSP_Recursive_Backtracking.py
    (Subset Sum Problem) Uses recursive backtracking to explore possible combinations of numbers that sum to a target value.

▶️ How to Run

  1. Ensure you have Python 3 installed.
  2. To run a script, open a command prompt in the project directory and execute:
    python Caesar-Cipher-Algorithm.py
  3. Modify the inputs within the script or integrate with input() as needed.

💡 Educational Goals

  • Understand classical encryption methods and their strengths/weaknesses.
  • Learn basic techniques of frequency-based cryptanalysis.
  • Explore core number-theoretic concepts that underpin modern cryptography.
  • Practice implementing real-world math-based problems in Python.

About

A Python-based collection of classical cryptographic algorithms and number theory utilities designed for educational purposes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages