124 lines
3.5 KiB
Markdown
124 lines
3.5 KiB
Markdown
# 🔐 DVT_RFSA — Hybrid Encryption Library
|
|
|
|
> A robust **hybrid encryption** library combining **RSA + X25519 + AES-256-GCM** for text & file encryption, with optional password protection.
|
|
|
|
**DVT_RFSA** is a Python cryptography library that implements hybrid encryption schemes:
|
|
- **AES-256-GCM** for data encryption
|
|
- **RSA-2048** and **X25519 (ECDH)** for key exchange
|
|
- Optional **password-derived key** protection (PBKDF2/HKDF)
|
|
- Support for encrypting text, files, and binary data
|
|
- Includes security metadata (algorithm, key info) for interchange
|
|
|
|
---
|
|
|
|
## ✨ Encryption Schemes
|
|
|
|
| Scheme | Description |
|
|
|--------|-------------|
|
|
| **AES + RSA** | Hybrid: AES-256-GCM session key wrapped with RSA-2048 public key |
|
|
| **AES + X25519** | Hybrid: AES-256-GCM session key via X25519 ECDH key exchange |
|
|
| **AES + RSA + Password** | Above + password-derived key layered encryption |
|
|
| **Pure AES** | Direct AES-256-GCM with generated/password-derived key |
|
|
|
|
---
|
|
|
|
## 🔌 Core Functions
|
|
|
|
### Hashing & Key Tools
|
|
- `compute_data_hash(data, algorithm='sha256')` / `verify_data_hash(...)`
|
|
- `generate_aes_key()` / `derive_key_from_password(...)`
|
|
- `is_password_strong(...)` / `generate_strong_password(...)`
|
|
|
|
### Key Generation
|
|
- `generate_rsa_key()` — RSA-2048 keypair
|
|
- `generate_x25519_keys()` — X25519 keypair
|
|
- `load_x25519_private_key(...)` / `load_x25519_public_key(...)`
|
|
|
|
### Data Encryption (text / bytes)
|
|
- `aes_encrypt` / `aes_decrypt`
|
|
- `encrypt_aes_rsa` / `decrypt_aes_rsa`
|
|
- `encrypt_aes_x25519` / `decrypt_aes_x25519`
|
|
- `encrypt_aes_rsa_with_password` / `decrypt_aes_rsa_with_password`
|
|
|
|
### File Encryption
|
|
- `encrypt_file_aes_rsa` / `decrypt_file_aes_rsa`
|
|
- `encrypt_file_aes_rsa_with_password` / `decrypt_file_aes_rsa_with_password`
|
|
- `encrypt_file_aes_x25519` / `decrypt_file_aes_x25519`
|
|
|
|
### Text Convenience
|
|
- `encrypt_text_aes_rsa` / `decrypt_text_aes_rsa`
|
|
- `encrypt_text_aes_rsa_with_password` / `decrypt_text_aes_rsa_with_password`
|
|
- `encrypt_text_aes_x25519` / `decrypt_text_aes_x25519`
|
|
|
|
### Metadata
|
|
- `add_security_info(...)` / `remove_security_info(...)`
|
|
|
|
---
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### Prerequisites
|
|
|
|
```bash
|
|
pip install cryptography
|
|
```
|
|
|
|
### Example: Encrypt/Decrypt a File (AES + RSA)
|
|
|
|
```python
|
|
import DVT_RFSA as rf
|
|
|
|
# Generate RSA keys
|
|
keys = rf.generate_rsa_key()
|
|
|
|
# Encrypt a file
|
|
rf.encrypt_file_aes_rsa("secret.txt", "secret.txt.enc", keys["public"])
|
|
|
|
# Decrypt the file
|
|
rf.decrypt_file_aes_rsa("secret.txt.enc", "secret_decrypted.txt", keys["private"])
|
|
```
|
|
|
|
### Example: Text Encryption with Password
|
|
|
|
```python
|
|
import DVT_RFSA as rf
|
|
|
|
password = rf.generate_strong_password()
|
|
enc = rf.encrypt_text_aes_rsa_with_password("Hello, world!", password)
|
|
dec = rf.decrypt_text_aes_rsa_with_password(enc, password)
|
|
print(dec) # Hello, world!
|
|
```
|
|
|
|
---
|
|
|
|
## 🛡️ Features
|
|
|
|
- **Authenticated encryption** (AES-256-GCM) — detects tampering
|
|
- **Hybrid key exchange** — RSA & X25519 (ECDH)
|
|
- **Password protection** — key derivation & layered encryption
|
|
- **File & text support** — encrypt whole files or strings
|
|
- **Portable output** — encrypted data carries security metadata
|
|
- **Debug logging** — optional `crypto_log` with timestamp
|
|
|
|
---
|
|
|
|
## 📁 Project Structure
|
|
|
|
```
|
|
dvt-rfsa/
|
|
├── DVT_RFSA.py # Hybrid encryption library
|
|
└── README.md # This document
|
|
```
|
|
|
|
---
|
|
|
|
## 📄 License
|
|
|
|
This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.
|
|
|
|
---
|
|
|
|
## ⚠️ Security Note
|
|
|
|
> This library is for **learning and reference**. For production, ensure secure key storage, use strong passwords, and review the cryptographic implementation carefully.
|