| Recommend this page to a friend! |
| Packages of Mohamed Abdulalim | Crypto | src/Reversible/README.md | Download |
|
|||||||||||||||||||||
? Reversible Crypto ModuleReversible / Symmetric Cryptography Engine This module provides a strict, fail-closed, reversible cryptography layer designed for systems that need to encrypt data and later decrypt it back to its original form. > ? This module is NOT for password hashing or one-way secrets. ? PurposeThis module is intended for use cases such as:
? Out of scope: - Password hashing - One-way hashing - Token signing - JWT / HMAC / integrity-only use cases ? Core Principle> Reversible cryptography is NOT hashing. This module explicitly supports: - Encryption and - Decryption back to the original plaintext Every class, interface, and name reflects this intent clearly. ? Architecture Overview
Separation of Responsibilities| Layer | Responsibility | |-----------------|-------------------------------| | Enum | Security whitelist & metadata | | Algorithm Class | Cryptographic execution | | Registry | Controlled algorithm binding | | Service | Orchestration only | | Bootstrap | Key loading & rotation policy | ? Module Structure
? Supported Algorithms (Whitelist)| Algorithm | AEAD | IV | Tag | Status | |-------------------|------|----|-----|------------| | AES-256-GCM | ?? | ?? | ?? | Default | | AES-128-GCM | ?? | ?? | ?? | Allowed | | ChaCha20-Poly1305 | ?? | ?? | ?? | Allowed | | AES-256-CBC | ? | ?? | ? | Restricted | ? ECB is forbidden ? Custom crypto is forbidden ? Key Rotation ModelThis module does NOT manage key rotation. It only:
Why?Key rotation is a key-management policy, not a cryptographic primitive. Rotation MUST be handled by:
?? Required Storage FieldsAny encrypted record MUST store: | Field | Required | |-----------|----------| | cipher | ?? | | algorithm | ?? | | key_id | ?? | | iv | nullable | | tag | nullable | This guarantees:
? Failure Semantics (Fail-Closed)This module never fails silently. Any failure results in an exception:
?? No fallbacks ?? No empty returns ?? No partial success ? Testing PhilosophyThe module is fully covered by unit tests:
Tests are:
? What This Module Does NOT Do
? Library-Ready DesignThis module is designed to be:
It can be moved to its own repository without renaming or refactoring. ? Summary?? Clear reversible crypto intent ?? Strong separation of concerns ?? Fail-closed security model ?? Algorithm-agnostic design ?? Ready for queues, jobs, and secure storage ?? Library-grade architecture Use responsibly. Cryptography is not forgiving. |