Skip to content

fahimed/CypherKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CypherKit

PyPI version License: MIT Python 3.7+

A Python library for cryptographic operations that secures data, encrypts files, protects passwords, sends secret messages, and hides text in images.

πŸš€ Features

πŸ” Password Management

  • Password Hashing: Turn passwords into secure hashes using PBKDF2 with salt
  • Password Verification: Check if entered passwords match stored hashes
  • Password Generation: Create random passwords with letters, numbers, and symbols

πŸ“ File Encryption

  • AES File Encryption: Encrypt files using AES-256 in GCM mode
  • Password-Based Encryption: Uses PBKDF2 to turn passwords into encryption keys
  • Automatic File Handling: Creates .enc files and restores original files

πŸ”— Data Hashing

  • SHA-256 Hashing: Create SHA-256 hashes for data verification
  • Hash Verification: Check if data matches its expected hash
  • Simple Hash Comparison: Quick way to detect data changes

πŸ’¬ Message Encryption

  • AES Message Encryption: Encrypt text messages using AES-256-GCM
  • Key-Based Encryption: Requires 32-byte keys for encryption/decryption
  • Base64 Output: Encrypted messages are returned as readable text strings

πŸ–ΌοΈ Image Steganography

  • LSB Steganography: Hide text messages in image pixels using least significant bits
  • PNG/Image Support: Works with images that PIL can open (PNG, JPEG, etc.)
  • Invisible Messages: Messages are hidden without noticeable visual changes

πŸ“‹ Requirements

  • Python 3.7 or higher
  • Dependencies:
    • pycryptodome >= 3.0.0
    • Pillow >= 8.0.0

πŸ› οΈ Installation

Using pip (Recommended)

pip install cypherkit

From Source

git clone https://github.com/FahimDidnt/CypherKit.git
cd CypherKit
pip install -e .

Development Installation

git clone https://github.com/FahimDidnt/CypherKit.git
cd CypherKit
pip install -e ".[dev]"

πŸ“– Quick Start

Password Management

from cypherkit import hash_password, verify_password, generate_password

# Hash a password securely
password = "my_secure_password"
hashed = hash_password(password)
print(f"Hashed: {hashed}")

# Verify password
is_valid = verify_password(hashed, password)
print(f"Password valid: {is_valid}")  # True

# Generate a secure random password
random_password = generate_password(length=16, include_symbols=True)
print(f"Generated password: {random_password}")

File Encryption

from cypherkit import encrypt_file, decrypt_file

# Encrypt a file
try:
    encrypt_file('sensitive_data.txt', 'strong_password_123')
    print("File encrypted successfully!")
except Exception as e:
    print(f"Encryption failed: {e}")

# Decrypt a file
try:
    decrypt_file('sensitive_data.txt.enc', 'strong_password_123')
    print("File decrypted successfully!")
except Exception as e:
    print(f"Decryption failed: {e}")

Secure Hashing

from cypherkit import generate_hash, verify_hash

# Generate hash for data integrity
data = "Important document content"
hash_value = generate_hash(data)
print(f"Hash: {hash_value}")

# Verify data integrity
is_valid = verify_hash(data, hash_value)
print(f"Data integrity valid: {is_valid}")  # True

Communication Encryption

from cypherkit import encrypt_message, decrypt_message
import os

# Generate a secure encryption key
encryption_key = os.urandom(32)  # 256-bit key

# Encrypt a message
message = "This is a confidential message"
encrypted_data = encrypt_message(message, encryption_key)
print("Message encrypted successfully!")

# Decrypt the message
decrypted_message = decrypt_message(encrypted_data, encryption_key)
print(f"Decrypted: {decrypted_message}")

Steganography

from cypherkit import encode_message, decode_message

# Hide a message in an image
secret_message = "This message is hidden in the image"
try:
    encode_message('cover_image.png', secret_message, 'stego_image.png')
    print("Message successfully hidden in image!")
except Exception as e:
    print(f"Steganography encoding failed: {e}")

# Extract the hidden message
try:
    extracted_message = decode_message('stego_image.png')
    print(f"Hidden message: {extracted_message}")
except Exception as e:
    print(f"Steganography decoding failed: {e}")

πŸ—οΈ Project Structure

cypherkit/
β”œβ”€β”€ cypherkit/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ password.py
β”‚   β”œβ”€β”€ file_crypto.py
β”‚   β”œβ”€β”€ hashing.py
β”‚   β”œβ”€β”€ communication.py
β”‚   β”œβ”€β”€ steganography.py
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ test_password.py
β”‚   β”œβ”€β”€ test_file_crypto.py
β”‚   β”œβ”€β”€ test_hashing.py
β”‚   β”œβ”€β”€ test_communication.py
β”‚   β”œβ”€β”€ test_steganography.py
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ setup.py

πŸ”’ Security Details

  • PBKDF2 Password Hashing: Uses 100,000 iterations with random salt for password protection
  • AES-256-GCM Encryption: Strong encryption with built-in authentication for files and messages
  • Secure Random Generation: Uses Python's secrets module for cryptographically strong randomness
  • Salt Protection: Automatic random salt generation prevents rainbow table attacks
  • Key Derivation: PBKDF2 safely converts passwords into encryption keys

πŸ§ͺ Testing

Run the test suite to ensure everything works correctly:

# Run all tests
python -m pytest tests/

# Run tests with coverage
python -m pytest tests/ --cov=cypherkit

# Run specific test module
python -m pytest tests/test_password.py -v

🀝 Contributing

I welcome contributions! Fork the repo, make your changes, and submit a pull request. Please report bugs and suggest features through GitHub issues.

Development Setup

  1. Fork the repository
  2. Create a virtual environment: python -m venv venv
  3. Activate it: source venv/bin/activate (Linux/Mac) or venv\Scripts\activate (Windows)
  4. Install development dependencies: pip install -e ".[dev]"
  5. Run tests: python -m pytest

Reporting Issues

Please report bugs and feature requests through GitHub Issues.

πŸ“„ License

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


About

A basic library for cryptographic operations like hashing, encryption, and steganography

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages