Skip to content

Tanvir-Mahamood/Security-and-Privacy

Repository files navigation

Cryptography Algorithms Implementation

A comprehensive collection of cryptographic algorithms implemented in Python, featuring both encryption and decryption capabilities with file-based input/output and visualization.

📚 Table of Contents

🔐 Overview

This repository contains implementations of various classical and modern cryptographic algorithms. Each implementation includes proper visualization and demonstrates encryption/decryption processes through file-based operations, making it easy to understand how these algorithms work in practice.

🛠️ Algorithms Implemented

  1. CryptoBasics - Classical Cryptography

    • 1.1. Caesar Cipher
    • 1.2. Mono Alphabetic Substitution Cipher
    • 1.3. Columnar Transposition Cipher
  2. DES - Data Encryption Standard

  3. Triple DES - Triple Data Encryption Standard

  4. AES - Advanced Encryption Standard

  5. RSA - Rivest–Shamir–Adleman Public-Key Cryptosystem

  6. Diffie-Hellman Algorithm - Key Exchange Protocol

  7. Man in the Middle Attack - Demonstration on Diffie-Hellman Key Exchange

✨ Features

  • File-based I/O: Read plaintext from input files and write ciphertext to output files
  • Encryption & Decryption: Complete implementation of both processes
  • Visualization: Clear demonstration of cryptographic processes
  • Educational: Well-structured code suitable for learning purposes
  • Multiple Algorithms: Classical to modern cryptographic techniques

📁 Project Structure

Security and Privacy Sessional/
│
├── CryptoBasics/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   └── ciphertext.txt
│
├── DES Data Encryption Standard/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   └── ciphertext.txt
│
├── Triple DES/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   └── ciphertext.txt
│
├── AES Advanced Encryption Standard/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   ├── ciphertext.txt
│   └── aes_debug_log.txt
│
├── RSA/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   └── ciphertext.txt
│
├── Diffie Hellman Algorithm/
│   ├── encription_main.py
│   ├── plaintext_sender.txt
│   ├── plaintext_receiver.txt
│   └── ciphertext.txt
│
└── Man in the Middle Attack/
    ├── encription_main.py
    ├── Alice_Inbox.txt
    ├── Bob_Inbox.txt
    ├── Darth_Receiving.txt
    └── Darth_Sending.txt

🔧 Installation

Prerequisites

  • Python 3.x
  • Required Python packages (install using pip):
pip install pycryptodome

Clone the Repository

git clone https://github.com/yourusername/cryptography-algorithms.git
cd cryptography-algorithms

🚀 Usage

Each algorithm is contained in its own directory with a main Python file (encription_main.py) and associated text files for input/output.

General Steps:

  1. Navigate to the desired algorithm directory
  2. Edit the plaintext_sender.txt file with your message
  3. Run the encryption/decryption script:
python encription_main.py
  1. View the results in the output files

Example: Running Caesar Cipher

cd "CryptoBasics"
python encription_main.py

The program will:

  • Read plaintext from plaintext_sender.txt
  • Encrypt the message
  • Write ciphertext to ciphertext.txt
  • Decrypt the ciphertext
  • Write decrypted text to plaintext_receiver.txt

📖 Algorithms Description

1. CryptoBasics

Classical Cryptography Techniques:

  • Caesar Cipher: Substitution cipher that shifts letters by a fixed number
  • Mono Alphabetic Substitution: Each letter is replaced by another letter according to a key
  • Columnar Transposition: Characters are rearranged based on a columnar pattern

2. DES (Data Encryption Standard)

A symmetric-key algorithm that uses a 56-bit key to encrypt 64-bit blocks of data through 16 rounds of permutation and substitution.

3. Triple DES (3DES)

An enhancement of DES that applies the DES cipher algorithm three times to each data block, providing stronger encryption.

4. AES (Advanced Encryption Standard)

Modern symmetric encryption standard using key sizes of 128, 192, or 256 bits. Considered highly secure and widely used today.

5. RSA

An asymmetric cryptographic algorithm using public and private keys. Based on the mathematical difficulty of factoring large prime numbers.

6. Diffie-Hellman Algorithm

A key exchange protocol that allows two parties to establish a shared secret key over an insecure channel.

7. Man in the Middle Attack

A demonstration of security vulnerabilities in the Diffie-Hellman key exchange, showing how an attacker (Darth) can intercept communications between Alice and Bob.

📝 License

This project is open-source and available for educational purposes.

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.

📧 Contact

For questions or suggestions, please open an issue in this repository.


⚠️ Disclaimer: This repository is intended for educational purposes only. Use these implementations to learn about cryptography, but rely on established cryptographic libraries for production systems.

About

A collection of my lab works, experiments, and implementations in the field of computer security. This repository serves as a practical hub for exploring fundamental and advanced concepts in information security, with a focus on hands-on coding.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages