Hide encrypted messages inside any file β invisibly.
Features β’ Installation β’ How It Works β’ Security β’ Roadmap
- Overview
- Features
- Installation
- Quick Start
- How It Works
- Security Analysis
- Demo
- Future Roadmap
- Contributing
- License
Encapsula is a terminal-based steganography tool that combines AES-256-GCM authenticated encryption with adaptive LSB steganography to hide secret messages inside ordinary files. Unlike traditional encryption that produces obvious encrypted files, Encapsula embeds your encrypted data within existing files (images, documents, executables, etc.), making the presence of hidden data nearly undetectable.
- π Authenticated Encryption: AES-256-GCM with built-in integrity verification
- π§ Adaptive Key Derivation: scrypt with memory-adaptive parameters (up to 2^15)
- ποΈ Invisible Storage: Messages hidden within normal files using LSB steganography
- π¨ Multi-Format Support: PNG (LSB), JPEG (APP15), WebP (custom chunk), generic (trailer)
- π Randomized Embedding: HMAC-based PRNG for secure pixel positioning in PNGs
- π« Zero Password Storage: Passwords never saved to disk
- π» Beautiful Terminal UI: Interactive command-line interface with progress tracking
- π― Simple Workflow: Upload β Message β Password β Done
| Feature | Description |
|---|---|
| AES-256-GCM Encryption | Authenticated encryption providing both confidentiality and integrity |
| scrypt Key Derivation | Memory-hard KDF with adaptive N (2^12 to 2^15) for brute-force resistance |
| LSB Steganography | Least Significant Bit embedding in PNG images with randomization |
| Multi-Format Embedding | PNG (LSB), JPEG (APP15 marker), WebP (chunk), generic files (trailer) |
| Authenticated Encryption | GCM mode provides cryptographic verification of data integrity |
| Random Salt & IV | Per-file cryptographic randomness prevents pattern analysis |
| Adaptive Parameters | Automatically adjusts to available system memory |
| Multi-line Messages | Support for complex, formatted secret messages |
| Interactive TUI | Terminal-based user interface with real-time progress tracking |
| Cross-Platform | Works on Windows, macOS, and Linux |
| Secure Memory Handling | Passwords cleared from memory after use |
| Auto-Download | Encoded files automatically copied to Downloads folder |
npx encapsulanpm install -g encapsula
encapsulagit clone https://github.com/admin12121/Encapsula.git
cd Encapsula
npm install
npm run build
npm start- Node.js 20 or higher
- Terminal with ANSI color support
- Minimum 128MB free RAM (512MB recommended for optimal scrypt parameters)
-
Launch Encapsula
npx encapsula
-
Navigate to Encode Tab (Press
Tabkey) -
Upload Host File (Press
Enter)- Select any file (PNG, JPEG, WebP, PDF, video, etc.)
- For best steganography: use PNG images
-
Enter Secret Message
- Type your multi-line message
- Press
Ctrl+Swhen finished
-
Set Password
- Enter a strong password (minimum 8 characters recommended)
- Press
Enter
-
Done!
- Encoded file saved to Downloads folder
- Original file remains unchanged
-
Navigate to Decode Tab (Press
Tab) -
Upload Encoded File
-
Enter Password (same as encoding)
-
View Decrypted Message
- Message displayed on screen
- Optionally saved to .dec.txt file
Encapsula uses a three-layer security approach: key derivation for password hardening, authenticated encryption for confidentiality and integrity, and steganography for concealment.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ENCODING WORKFLOW β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββ
β User Input β
β (Message + β
β Password) β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 1. Generate Random Salt & IV β
β β’ Salt: 16 random bytes β
β β’ IV: 12 random bytes (GCM) β
β β’ crypto.randomBytes() - CSPRNG β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 2. Key Derivation (scrypt) β
β β’ Password + Salt β scrypt KDF β
β β’ Adaptive N: 2^15 β 2^12 (512MB mem)β
β β’ Parameters: r=8, p=1 β
β β’ Output: 32-byte AES-256 key β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 3. Authenticated Encryption (AES-GCM) β
β β’ Algorithm: AES-256-GCM β
β β’ Input: plaintext message β
β β’ Output: ciphertext + 16-byte tag β
β β’ Tag verifies integrity β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 4. Build 60-Byte Header β
β β’ Magic: "ECAP" (4) β
β β’ Version, flags, params (8) β
β β’ Payload length (4) β
β β’ KDF params: kdf, logN, r, p (4) β
β β’ Salt (16), IV (12), Tag (16) β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 5. Format-Specific Embedding β
β β
β ββ PNG: LSB Steganography β
β β β’ Header: LSB in first N pixels β
β β β’ Payload: randomized LSB positions β
β β β’ HMAC-PRNG shuffles pixel indices β
β β β’ 1-2 bits per RGB channel β
β β β
β ββ JPEG: APP15 Marker Segment β
β β β’ Insert after SOI marker β
β β β’ Header + ciphertext in marker β
β β β
β ββ WebP: Custom Chunk β
β β β’ Insert as WebP chunk β
β β β’ Follows WebP RIFF structure β
β β β
β ββ Other: Trailer Append β
β β’ Signature: "ECAPTR" (6) β
β β’ Length (4) + Header + Ciphertext β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Output File β
β (Carrier + β
β Hidden) β
ββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DECODING WORKFLOW β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ββββββββββββββββ
β Encoded File β
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 1. Detect Carrier Type & Extract Data β
β β
β ββ PNG: LSB Extraction β
β β β’ Read header from LSB bits β
β β β’ Parse randomization flag β
β β β’ Extract payload using HMAC-PRNG β
β β β
β ββ JPEG: Find APP15 Marker β
β β β’ Scan for APP15 segment β
β β β’ Extract header + ciphertext β
β β β
β ββ WebP: Find Custom Chunk β
β β β’ Parse WebP structure β
β β β’ Extract chunk data β
β β β
β ββ Other: Find Trailer β
β β’ Search for "ECAPTR" signature β
β β’ Read length, extract payload β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 2. Parse 60-Byte Header β
β β’ Verify magic: "ECAP" β
β β’ Check version compatibility β
β β’ Extract: salt, IV, tag, params β
β β’ Read payload length β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 3. Key Derivation (scrypt) β
β β’ User password + extracted salt β
β β’ Use stored logN, r, p parameters β
β β’ Must match encoding key exactly β
β β’ Output: 32-byte AES key β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β 4. Authenticated Decryption (AES-GCM) β
β β’ Use extracted IV and tag β
β β’ Decrypt ciphertext β
β β’ Verify authentication tag β
β β’ Fails if tampered/wrong password β
ββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββ
β Original β
β Message β
β (Plaintext) β
ββββββββββββββββ
Encapsula uses scrypt, a memory-hard key derivation function designed to resist hardware-accelerated brute-force attacks:
Password (User Input)
β
Random 16-byte Salt (per file)
β
scrypt(password, salt, N, r, p)
β’ N = 2^logN (adaptive: 2^15 to 2^12)
β’ r = 8 (block size)
β’ p = 1 (parallelization)
β’ maxmem = 512MB
β
32-byte AES-256 Key
Why scrypt over PBKDF2?
- Memory-Hard: Requires significant RAM, making GPU/ASIC attacks expensive
- Adaptive: Automatically reduces N on memory-constrained systems
- Strong Default: N=2^15 (32,768 iterations) is ~32x stronger than typical PBKDF2
- Time-Memory Tradeoff: Attackers cannot trade time for memory
Adaptive Algorithm:
Try N = 2^15 (preferred)
β
If memory error β reduce to 2^14
β
If memory error β reduce to 2^13
β
Continue until success (minimum 2^12)
The chosen logN is stored in the header, ensuring proper decryption.
Encapsula uses AES-256-GCM (Galois/Counter Mode), providing both confidentiality and integrity:
Plaintext Message + Random 12-byte IV + 32-byte Key
β
AES-256-GCM Encryption
β
Ciphertext + 16-byte Authentication Tag
AES-256-GCM Properties:
- Block Cipher: AES with 256-bit key
- Mode: Galois/Counter Mode (authenticated encryption)
- IV Size: 12 bytes (96 bits) - optimal for GCM
- Tag Size: 16 bytes (128 bits) - prevents tampering
- Authentication: Tag cryptographically verifies data integrity
Security Benefits:
- β Confidentiality: Message content hidden from adversaries
- β Integrity: Detects any modification to ciphertext
- β Authenticity: Verifies data hasn't been tampered with
- β No Padding Oracles: GCM is a stream cipher mode
- β Parallel Processing: Faster than CBC mode
Encapsula adapts its embedding strategy based on file type:
For PNG images, Encapsula uses Least Significant Bit (LSB) embedding with optional randomization:
Basic LSB Embedding:
Original Pixel: RGB(11010110, 10110011, 01011010)
β β β
Embed 3 bits (1,0,1):
Modified Pixel: RGB(11010111, 10110010, 01011011)
β β β
(LSB changed to match data bits)
Randomized Positioning (FLAG_RANDOMIZED):
- Generate HMAC-based PRNG from password
- Shuffle pixel indices pseudo-randomly
- Embed bits in shuffled order
- Decoder uses same PRNG to reconstruct order
Capacity Calculation:
Header: 60 bytes Γ 8 bits = 480 bits (stored in first 480 LSBs)
Payload: Remaining RGB bytes Γ bits_per_channel
β’ 1 bit/channel: capacity = (pixels Γ 3) - 480 bits
β’ 2 bits/channel: capacity = (pixels Γ 6) - 480 bits
Example: 1920Γ1080 PNG (2,073,600 pixels)
- 1-bit mode: ~776 KB capacity
- 2-bit mode: ~1.5 MB capacity
JPEG format allows custom application-specific marker segments:
JPEG Structure:
[SOI][APP0 (JFIF)][...image data...][EOI]
β
[SOI][APP15 (Encapsula)][APP0][...image data...][EOI]
β
Header + Ciphertext stored here
Advantages:
- β Standard JPEG structure maintained
- β Most viewers ignore unknown markers
- β No visual artifacts
- β Fast extraction (no pixel processing)
WebP uses a chunk-based RIFF container format:
WebP Structure:
RIFF[size][WEBP][VP8 ...][ALPH ...][EXIF ...]
β
RIFF[size][WEBP][VP8 ...][ECAP (Encapsula)][ALPH ...]
β
Custom chunk with payload
For files without format-specific embedding:
[Original File Content][EOF]
β
[Original File Content][ECAPTR][Length][Header][Ciphertext][ECAPTR]
β β
Start signature End signature
Trailer Structure:
Offset | Size | Description
--------|----------|-------------------------------------------
0 | 6 bytes | Signature: "ECAPTR" (Encapsula Trailer)
6 | 4 bytes | Payload length (Big Endian UInt32)
10 | 60 bytes | Header (salt, IV, tag, params)
70 | N bytes | Ciphertext
70+N | 6 bytes | End signature: "ECAPTR"
Why This Works:
- Most programs ignore trailing data after EOF
- PDFs, executables, videos remain functional
- Large capacity (limited only by filesystem)
- Fast extraction via signature search
| Security Feature | Implementation | Benefit |
|---|---|---|
| AES-256-GCM | Authenticated encryption with 256-bit keys | Quantum-resistant symmetric encryption |
| Random IVs | crypto.randomBytes(12) per message | Prevents pattern analysis and replay attacks |
| Random Salts | crypto.randomBytes(16) per file | Prevents rainbow table attacks |
| scrypt KDF | Memory-hard with adaptive N (2^12β2^15) | Resists GPU/ASIC brute-force attacks |
| Authentication Tag | 128-bit GCM tag | Detects tampering and wrong passwords |
| No Password Storage | Cleared from memory post-use | No plaintext password leakage |
| Steganographic Concealment | Hidden within normal files | Reduces detection probability |
| Randomized Embedding | HMAC-PRNG for PNG positioning | Prevents statistical analysis |
| Adaptive Security | Adjusts to system capabilities | Balances security and compatibility |
Key Space:
- AES-256: 2^256 possible keys (~10^77)
- Brute force time: Billions of years with current technology
scrypt Parameters (N=2^15, r=8, p=1):
- Memory required: ~64 MB per attempt
- Makes parallel attacks (GPU/ASIC) prohibitively expensive
- Estimated cost: >$1 million to crack a strong password
GCM Authentication:
- 128-bit tag provides 2^128 security against forgery
- Probability of successful random tag: 1 in 340 trillion trillion trillion
Issue: Weak passwords reduce effective security
Mitigation:
- scrypt makes brute-force expensive even for moderate passwords
- Recommend 12+ character passwords with mixed case, numbers, symbols
- Tool does not enforce password policy (user responsibility)
Issue: High-capacity embedding in PNGs may cause subtle visual artifacts with 2-bit LSB
Mitigation:
- Default to 1-bit mode for visual quality
- 2-bit mode only for large payloads
- Use JPEG/WebP/trailer for maximum stealth
Issue: Some aggressive compression/optimization may strip hidden data
Risk: JPEG re-encoding, PNG optimization, PDF compression
Mitigation:
- Store backups of encoded files
- Verify integrity after file transfers
- Use lossless formats when possible
Issue: File modification timestamps may indicate alteration
Mitigation:
- Not currently addressed in v1.x
- Planned for v2.0: timestamp preservation option
Issue: Password strings may briefly exist in JavaScript heap
Risk: Low (requires privileged system access during encoding)
Mitigation:
- Passwords cleared immediately after use
- Future: Use secure buffer implementations
What Encapsula Protects Against:
- β Passive observers (steganography conceals existence)
- β Brute-force attacks (scrypt + strong passwords)
- β Rainbow tables (random salts)
- β Data tampering (GCM authentication tags)
- β Chosen-plaintext attacks (random IVs)
- β Bit-flipping attacks (authenticated encryption)
What Encapsula Does NOT Protect Against:
- β Weak user passwords (tool cannot force strong passwords)
- β Keyloggers or malware (operating system security required)
- β Targeted statistical analysis by experts (LSB has detectable patterns)
- β Quantum computers (in far future, AES-256 remains strong)
- β Social engineering (user must keep password secret)
Interactive terminal interface showing the encode/decode workflow
Contributions are welcome! Here's how you can help:
- Report Bugs β Open an issue with reproduction steps
- Suggest Features β Propose enhancements via GitHub Discussions
- Submit PRs β Fix bugs or implement features
- Security Audits β Help identify vulnerabilities (responsible disclosure)
- Documentation β Improve guides, add examples
- Testing β Write unit/integration tests
# Clone repository
git clone https://github.com/admin12121/Encapsula.git
cd Encapsula
# Install dependencies
npm install
npm i --save-dev @types/pngjs
# Build TypeScript
npm run build
# Run in development mode
npm run dev
# Run production build
npm startEncapsula/
βββ src/
β βββ index.ts # Entry point, tab navigation
β βββ data.ts # Configuration and constants
β βββ loader.ts # Startup/shutdown animations
β βββ sections/
β β βββ home.ts # Home screen with ASCII art
β β βββ encode.ts # Encoding workflow (600+ lines)
β β βββ decode.ts # Decoding workflow (500+ lines)
β βββ terminal/
β β βββ index.ts # Terminal rendering and viewport
β β βββ commands.ts # Command processing
β βββ ui/
β βββ filePicker.ts # File selection dialog
βββ dist/ # Compiled JavaScript (git ignored)
βββ assets/ # Screenshots and media
βββ package.json
βββ tsconfig.json
βββ README.md
npm test- TypeScript strict mode enabled
- ESLint for code quality
- Secure crypto practices (no hardcoded keys, proper RNG)
- Memory safety (buffer clearing, no leaks)
- Error handling (graceful degradation)
This project is licensed under the MIT License β see LICENSE file for details.
MIT License
Copyright (c) 2024 admin12121
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Encapsula is provided for educational and legitimate privacy purposes only.
- βοΈ This tool is not intended for illegal activities
- π€ Users are responsible for compliance with local laws and regulations
- π« The author assumes no liability for misuse or damages
- π Security depends on strong passwords and proper operational security
- π No encryption is 100% unbreakable β use defense in depth
Legal Notice:
- Encryption laws vary by jurisdiction (check local regulations)
- Some countries restrict or ban cryptography without approval
- Export restrictions may apply in certain regions
- Corporate/enterprise use may require legal review
Best Practices:
- Use strong, unique passwords (12+ characters, mixed case, symbols)
- Keep software updated for latest security patches
- Store backups of important encoded files
- Do not reuse passwords across different files
- Securely delete original plaintext after encoding
- Verify file integrity after transfers
Remember: Security is a process, not a product. Always combine cryptographic tools with sound operational security practices.
- Node.js Crypto Module β For cryptographic primitives (AES, scrypt, HMAC)
- terminal-kit β For beautiful terminal UI rendering
- pngjs β For PNG parsing and manipulation
- jpeg-js β For JPEG format handling
- Open Source Community β For inspiration, tools, and security research
- Cryptography Researchers β For developing and analyzing scrypt, AES-GCM
- InfoSec Community β For responsible disclosure and security improvements
