11 / CRYPTOGRAPHY

Hybrid File Encryption Tool

Production-grade file encryption with AES-256-GCM and RSA hybrid cryptography, HMAC integrity verification, secure key management, and professional UI. Built with Flask and React.

CryptographyAES-256RSAFlaskReact

Project overview

A professional-grade file encryption and decryption application demonstrating deep knowledge of cryptographic systems and secure software design. Combines password-based symmetric encryption with RSA public-key cryptography for flexible, real-world security scenarios.

Cryptographic design

AES-256-GCM (Password-Based)

  • Symmetric encryption: Advanced Encryption Standard with 256-bit keys for strong, fast file protection.
  • Galois/Counter Mode (GCM): Authenticated encryption that prevents tampering—no separate MAC needed.
  • PBKDF2 key derivation: 100,000 iterations of PBKDF2-HMAC-SHA256 to harden passwords against brute-force attacks.
  • Random nonce generation: 96-bit cryptographically-secure random nonces for GCM mode.
  • Defense-in-depth: Additional HMAC-SHA256 verification for redundant integrity checking.

RSA Hybrid Encryption

  • Key exchange: RSA (2048/3072/4096-bit) encrypts ephemeral AES keys for secure multi-party file sharing.
  • Bulk encryption: AES-256-GCM handles large files efficiently; only the AES key is encrypted with RSA.
  • OAEP padding: Optimal Asymmetric Encryption Padding with SHA-256 for robust RSA security.
  • Key management: Generate, store, and manage RSA keypairs with PEM serialization.
  • Use case: Share encrypted files securely even over insecure channels—only the holder of the private key can decrypt.

Security features

  • Authenticated encryption: GCM mode prevents bit-flipping and tampering attacks.
  • Constant-time comparison: HMAC verification uses constant-time functions to prevent timing attacks.
  • Secure randomness: Cryptographically-secure random generation for salts and nonces.
  • Industry algorithms: NIST-approved AES, PBKDF2, RSA, and HMAC.
  • Iteration hardening: 100,000 PBKDF2 iterations (NIST SP 800-132 recommended).
  • Salt isolation: Unique salt per encryption prevents rainbow table attacks.

Technical implementation

Cryptography Module (`crypto.py`): Core encryption/decryption logic using the `cryptography` library (industry-standard Python wrapper around OpenSSL).

Flask REST API: Endpoints for password-based and hybrid encryption, key generation, and key management. Stateless design for scalability.

React UI: Dark terminal aesthetic, tabbed interface for encrypt/decrypt workflows, key visualization, and download/copy functionality.

API Design: RESTful architecture with JSON payloads containing encrypted data, metadata (timestamps, filenames), and cryptographic artifacts (salt, nonce, tag).

Supported operations

  • Password encryption: File → AES-256-GCM (password-derived key) → JSON output
  • Password decryption: JSON input + password → AES-256-GCM decryption → Original file
  • RSA key generation: Generate 2048/3072/4096-bit keypairs on-demand
  • Hybrid encryption: File → AES-256-GCM + RSA-encrypted key → JSON output
  • Hybrid decryption: JSON + private key → Recover AES key → Decrypt file
  • Key management: Store, list, retrieve, and delete RSA keys

Use cases

  • Personal data protection: Encrypt sensitive documents at rest before cloud storage.
  • Secure file sharing: Exchange encrypted files over insecure channels (email, Slack, etc.).
  • Compliance: Meet GDPR, HIPAA, PCI-DSS requirements for data encryption.
  • Zero-trust workflows: Encrypt data before uploading to untrusted services.
  • Backup security: Protect backups end-to-end before archival.
  • Multi-party exchange: RSA key infrastructure for secure distribution networks.

Performance characteristics

  • AES-256 encryption: ~100-500 MB/s (CPU-dependent)
  • RSA key generation: ~0.5s (2048-bit), ~2-3s (4096-bit)
  • PBKDF2 derivation: ~100ms per password (intentionally slow for security)
  • File processing: In-memory; limited by available RAM

Cryptographic specifications

AES-256-GCM: 256-bit key, 96-bit nonce, 128-bit authentication tag.

PBKDF2: 100,000 iterations, SHA-256 hash, 16-byte salt.

RSA: 2048/3072/4096-bit keys, OAEP padding, MGF1-SHA256.

HMAC: HMAC-SHA256 for additional integrity verification.

Production readiness: Code follows cryptographic best practices; suitable for real-world deployment with proper key management infrastructure. In-memory key storage shown as demo; production systems should use hardware security modules (HSM) or secure enclaves.

Code and documentation

View on GitHub

Return to portfolio