Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Cryptography Project - S-DES & S-AES Implementation

A comprehensive implementation of Simplified Data Encryption Standard (S-DES) and Simplified Advanced Encryption Standard (S-AES) with support for multiple operation modes and various file types.

✨ Features

🔢 Encryption Algorithms

  • S-DES (Simplified Data Encryption Standard) 🛡️

    • 10-bit key encryption
    • 8-bit block cipher
    • Educational implementation of DES principles
  • S-AES (Simplified Advanced Encryption Standard) 🔐

    • 16-bit key encryption
    • 16-bit block cipher
    • Simplified version of AES for learning purposes

🔄 Operation Modes

Both S-DES and S-AES support the following 5 operation modes:

  1. ECB (Electronic Codebook) 📚

    • Each block encrypted independently
    • Simple but less secure for repetitive data
  2. CBC (Cipher Block Chaining) 🔗

    • Each block XORed with previous ciphertext
    • Requires initialization vector (IV)
  3. CFB (Cipher Feedback) 🔄

    • Stream cipher mode
    • Encryption of IV creates keystream
  4. OFB (Output Feedback) 🔁

    • Stream cipher mode
    • IV encrypted repeatedly to generate keystream
  5. CTR (Counter) 🔢

    • Stream cipher mode
    • Counter encrypted to generate keystream

📁 Supported File Types

  • Images: Process image files with encryption/decryption 🖼️
  • Videos: Handle video file encryption (.mp4 format) 🎥
  • Text Files: Encrypt/decrypt text documents (.txt format) 📄
  • JSON: Configuration and key files 📋

🚀 Additional Features

  • Brute Force Attack: Implement brute force decryption for text files 💥
  • Key Generation: Automatic key generation utilities 🔑
  • File I/O: Robust file handling for various formats 📂

Project Structure 📁

Crypto/
├── s-aes/ 🔐
│   ├── CBC.py          # 🔗 Cipher Block Chaining mode
│   ├── CFB.py          # 🔄 Cipher Feedback mode
│   ├── CTR.py          # 🔢 Counter mode
│   ├── ECB.py          # 📚 Electronic Codebook mode
│   ├── OFB.py          # 🔄 Output Feedback mode
│   ├── S-AES.json      # ⚙️ Configuration file
│   ├── S_AES_Decryption.py  # 🔓 Main decryption module
│   ├── S_AES_Encryption.py  # 🔒 Main encryption module
│   ├── key.json        # 🔑 Key storage
│   ├── text.txt        # 📄 Sample text file
│   ├── video.mp4       # 🎥 Sample video file
│   └── Class Diagram1.jpg   # 📊 Project documentation
│
├── s-des/ 🛡️
│   ├── CBC.py          # 🔗 Cipher Block Chaining mode
│   ├── CFB.py          # 🔄 Cipher Feedback mode
│   ├── CTR.py          # 🔢 Counter mode
│   ├── ECB.py          # 📚 Electronic Codebook mode
│   ├── OFB.py          # 🔄 Output Feedback mode
│   ├── S-DES.json      # ⚙️ Configuration file
│   ├── S_DES_decryption.py  # 🔓 Main decryption module
│   ├── S_DES_encryption.py  # 🔒 Main encryption module
│   ├── text.txt        # 📄 Sample text file
│   ├── text_recovered.txt   # 🔄 Recovered text file
│   ├── video.mp4       # 🎥 Sample video file
│   └── Class Diagram1.jpg   # 📊 Project documentation
│
├── .gitignore          # 📝 Git ignore rules
├── README.md           # 📖 Project documentation
└── key.json            # 🔑 Global key storage

🚀 Installation

  1. Clone the repository:
git clone [repository-url]
cd Crypto
  1. Install required dependencies:
pip install -r requirements.txt

💻 Usage

S-AES Implementation 🔐

Encryption 🔒

from S_AES_Encryption import encrypt_file

# Encrypt a text file
encrypt_file('input.txt', 'output.enc', key='your-16-bit-key', mode='CBC')

# Encrypt an image
encrypt_file('image.jpg', 'image.enc', key='your-16-bit-key', mode='ECB')

Decryption 🔓

from S_AES_Decryption import decrypt_file

# Decrypt a file
decrypt_file('encrypted.enc', 'decrypted.txt', key='your-16-bit-key', mode='CBC')

S-DES Implementation 🛡️

Basic Usage

from S_DES_encryption import s_des_encrypt
from S_DES_decryption import s_des_decrypt

# Encrypt/decrypt with S-DES
plaintext = "Hello"
key = "1010000010"  # 10-bit key
encrypted = s_des_encrypt(plaintext, key)
decrypted = s_des_decrypt(encrypted, key)

🔧 Operation Modes

ECB Mode 📚

from ECB import encrypt_ecb, decrypt_ecb
result = encrypt_ecb(data, key)

CBC Mode 🔗

from CBC import encrypt_cbc, decrypt_cbc
result = encrypt_cbc(data, key, iv)

CFB Mode 🔄

from CFB import encrypt_cfb, decrypt_cfb
result = encrypt_cfb(data, key, iv)

OFB Mode 🔁

from OFB import encrypt_ofb, decrypt_ofb
result = encrypt_ofb(data, key, iv)

CTR Mode 🔢

from CTR import encrypt_ctr, decrypt_ctr
result = encrypt_ctr(data, key, counter)

💥 Brute Force Attack

For educational purposes, implement brute force attacks on encrypted text:

def brute_force_text(encrypted_text, known_plaintext=None):
    """
    Attempt to decrypt text using brute force method 🔓💪
    """
    # Implementation for trying all possible keys
    pass

📂 File Format Support

Text Files (.txt) 📄

  • Direct encryption/decryption of text content
  • Support for various encodings (UTF-8, ASCII)
  • Includes text_recovered.txt for brute force results

Images 🖼️

  • Pixel-level encryption
  • Maintains image structure while encrypting pixel data
  • Supports common formats (JPEG, PNG)

Videos (.mp4) 🎥

  • Frame-by-frame encryption
  • Maintains video container structure
  • Encrypts video stream data

Security Notes

⚠️Educational Purpose Only: This implementation is designed for educational purposes to understand cryptographic principles. Do not use for production security applications.

  • S-DES and S-AES are simplified versions with reduced security
  • Real-world applications should use proven cryptographic libraries
  • Keys should be generated using cryptographically secure random generators

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

Educational Resources

This project demonstrates:

  • Block cipher operation modes
  • Symmetric encryption principles
  • File handling in cryptographic contexts
  • Brute force attack methodologies
  • Key management practices

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Based on educational materials for cryptography courses
  • Implements simplified versions of industry-standard algorithms
  • Designed for learning and demonstration purposes

About

Project Info431: Crypto S-DES and S-AES. Spring 2025

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages