obscr 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,92 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.1] - 2026-01-20
9
+
10
+ ### Added
11
+ - `.npmignore` file to exclude tests and development files from npm package
12
+ - 23 new CLI integration tests for command-line interface validation
13
+ - 3 additional steg unit tests for edge case validation
14
+
15
+ ### Changed
16
+ - Interactive mode now runs by default when no command is provided
17
+ - Improved spacing throughout CLI output for better readability
18
+ - Package size reduced (only production files included in npm package)
19
+
20
+ ### Fixed
21
+ - Fixed boxen borderColor compatibility issue (changed from "violet" to "magenta")
22
+
23
+ ### Testing
24
+ - Total test count: 103 tests (up from 80)
25
+ - Overall coverage: 90.45%
26
+ - All tests passing
27
+
28
+ ## [0.2.0] - 2026-01-20
29
+
30
+ ### Added
31
+ - **Compression Support**: Optional gzip compression using `--compress` flag to reduce message size by 50-90%
32
+ - **Custom Output Filename**: `-o/--output` flag for encrypt command to specify output filename (default: "encoded.png")
33
+ - **Image Capacity Validation**: Automatic validation that message fits in image with helpful error messages
34
+ - **Capacity Information**: Shows capacity utilization after successful encryption
35
+ - **Comprehensive Test Suite**: 80 tests with 90%+ code coverage
36
+ - Unit tests for crypto (100% coverage), utils (100% coverage), and steg (97% coverage)
37
+ - Integration tests for full workflows
38
+ - Automated test fixtures and isolated test outputs
39
+ - **JSDoc Documentation**: All exported functions now have detailed JSDoc comments
40
+ - **Enhanced README**: Comprehensive documentation with examples, security notes, and technical details
41
+
42
+ ### UX Enhancements
43
+ - **Interactive Mode**: New `obscr interactive` command with guided menu-driven workflow
44
+ - **Progress Indicators**: Real-time spinners showing encryption/decryption progress with ora
45
+ - **Visual Feedback**: Color-coded messages with icons (✔, ✖, ℹ, ⚠) and beautiful boxed outputs
46
+ - **Verbose Mode**: `-v/--verbose` flag for detailed technical information and debugging
47
+ - **Quiet Mode**: `-q/--quiet` flag for minimal output, perfect for scripting and automation
48
+ - **Confirmation Prompts**: Asks before overwriting existing files
49
+ - **Examples Command**: New `obscr examples` command showing usage examples
50
+ - **Better Help Text**: Improved help messages with clearer descriptions
51
+ - **Welcome Banner**: Stylish welcome banner with version information (can be suppressed with --quiet)
52
+ - **Password Masking**: Visual asterisks when entering passwords
53
+ - **Smart Validation**: Real-time input validation with helpful error messages
54
+
55
+ ### Changed
56
+ - **Async/Await Pattern**: Replaced synchronous crypto operations with async Promise-based approach for better performance
57
+ - **Modern JavaScript**: Converted `var` to `const`/`let`, using template literals throughout
58
+ - **Better Variable Names**: Improved naming for clarity (e.g., `c` → `currentByte`, `tmp` → `powerOfTwo`)
59
+ - **Error Handling**: Consistent error handling with structured return types `{success, data, error}`
60
+ - **Return Types**: Changed from tuple returns `[boolean, data]` to objects for better clarity
61
+ - **Array Optimizations**: Pre-allocated arrays instead of dynamic growth
62
+
63
+ ### Fixed
64
+ - **Debug Output Removed**: Removed debug `console.log` statement in encrypt command
65
+ - **Error Object Handling**: Now throws proper Error objects instead of strings
66
+ - **Fixed Output Filename**: Encrypt command now supports custom output instead of hardcoded "encoded.png"
67
+
68
+ ### Security
69
+ - **Backward Compatibility Maintained**:
70
+ - SECRET_KEY preserved for compatibility with older encrypted images
71
+ - Can decrypt images created with previous versions
72
+ - Automatically detects compressed vs uncompressed messages
73
+ - All encryption parameters unchanged (AES-256-GCM, PBKDF2 with 65,535 iterations)
74
+
75
+ ### Technical Notes
76
+ - Compression format adds optional 5th field: `salt:nonce:ciphertext:tag[:1]`
77
+ - Async operations provide foundation for future streaming implementations
78
+ - Test outputs isolated in `test/output/` directory and properly gitignored
79
+
80
+ ## [0.1.2] - 2022-09-11
81
+
82
+ ### Changed
83
+ - Updated dependencies
84
+ - Cleaned up codebase
85
+
86
+ ## [0.1.1] - 2022-07-08
87
+
88
+ ### Added
89
+ - Initial release with AES-256-GCM encryption
90
+ - LSB steganography for PNG images
91
+ - Password-based key derivation with PBKDF2
92
+ - CLI interface with encrypt/decrypt commands
package/README.md CHANGED
@@ -1,72 +1,260 @@
1
1
  <p align="center">
2
-
2
+
3
3
  </p>
4
4
  <p align="center">
5
5
  <img src="https://img.shields.io/badge/license-MIT-green">
6
6
  <img src="https://img.shields.io/badge/build-passing-brightgreen">
7
- <img src="https://img.shields.io/badge/version-0.1.1-orange">
7
+ <img src="https://img.shields.io/badge/version-0.1.2-orange">
8
8
  <img src="https://img.shields.io/badge/npm-v8.3.1-blue">
9
9
  <img src="https://img.shields.io/badge/node-v16.14.0-yellow">
10
10
  </p>
11
11
  <br>
12
- <p align="center">A CLI to encrypt data inside images.</p>
12
+ <p align="center">Encrypt and hide your secure data using AES-256-GCM encryption combined with steganography</p>
13
13
  <br>
14
14
 
15
15
  ---
16
16
 
17
- ## Description
17
+ ## Features
18
+
19
+ ### Security
20
+ - **Strong Encryption**: Uses AES-256-GCM for message encryption
21
+ - **Steganography**: Hides encrypted messages in PNG images using LSB (Least Significant Bit) technique
22
+ - **Compression**: Optional gzip compression to fit larger messages in smaller images (50-90% reduction)
23
+ - **Password-Based Key Derivation**: PBKDF2 with SHA-512 for secure key generation (65,535 iterations)
24
+ - **Data Obfuscation**: Password-seeded scrambling of data bits within the image
25
+ - **Backward Compatible**: Can decrypt messages from older versions
18
26
 
19
- CLI tool to encrypt secret messages with AES-256-GCM and a password.
20
- Same password will then be used as a seed to generate a random order in which the encrypted message will be encoded inside the specified .png image.
27
+ ### User Experience
28
+ - **Interactive Mode**: Guided workflow with menu-driven interface for beginners
29
+ - **Progress Indicators**: Real-time spinners showing encryption/decryption progress
30
+ - **Visual Feedback**: Color-coded messages, icons, and beautiful boxed outputs
31
+ - **Verbose Mode**: Detailed technical information for debugging and learning
32
+ - **Quiet Mode**: Minimal output perfect for scripting and automation
33
+ - **Confirmation Prompts**: Prevents accidental file overwrites
34
+ - **Smart Validation**: Input validation with helpful error messages
35
+ - **Usage Examples**: Built-in examples command for quick reference
21
36
 
22
37
  ## NPM package
23
38
 
24
- ```
39
+ ```bash
25
40
  npm install -g obscr
26
41
  ```
27
42
 
28
43
  ## Usage
29
44
 
45
+ ### Interactive Mode (Recommended for Beginners)
46
+
47
+ ```bash
48
+ obscr interactive
30
49
  ```
31
- ~$ obscr --help
32
- Usage: obscr <cmd> [options]
33
50
 
34
- Commands:
35
- obscr encrypt Encrypts and hides the message into an image.
36
- obscr decrypt Decrypts message from image.
51
+ Launches a guided workflow with menu-driven interface. Perfect for first-time users!
37
52
 
38
- Options:
39
- --version Show version number [boolean]
40
- --help Show help [boolean]
53
+ ### Command Line Mode
41
54
 
42
- copyright 2022
55
+ #### Encrypt and Hide a Message
43
56
 
57
+ ```bash
58
+ obscr encrypt -f <input-image.png> [-o <output-image.png>] [--compress] [--verbose] [--quiet]
44
59
  ```
45
60
 
46
- > :warning: **Only tested with png images**
61
+ **Options:**
62
+ - `-f, --filename`: Path to the PNG image to use as a container (required)
63
+ - `-o, --output`: Output filename for the encoded image (default: "encoded.png")
64
+ - `-c, --compress`: Enable compression to fit larger messages (50-90% reduction)
65
+ - `-v, --verbose`: Show detailed progress and technical information
66
+ - `-q, --quiet`: Minimal output (only essential messages)
47
67
 
48
- <br>
68
+ **Examples:**
69
+ ```bash
70
+ # Basic usage with visual feedback
71
+ obscr encrypt -f photo.png
49
72
 
50
- ## Installation
73
+ # With compression and custom output
74
+ obscr encrypt -f photo.png -o secret.png --compress
51
75
 
52
- 1. Clone the repository and then navigate to it.
53
- 2. Run `npm install` to install the dependencies.
54
- 3. Run `npm install -g .` to install the CLI. <br>
76
+ # Verbose mode for detailed information
77
+ obscr encrypt -f photo.png --verbose
55
78
 
56
- > :warning: **This might cause an error** which can be resolved easily by using `sudo` with the command, **however**, using `sudo` with `npm` is **not recommended** because it might cause permission issues later. So instead put the code below in your .bashrc file and then run the above command again.
79
+ # Quiet mode for scripts
80
+ obscr encrypt -f photo.png -o output.png --quiet
81
+ ```
82
+
83
+ #### Decrypt and Extract a Message
84
+
85
+ ```bash
86
+ obscr decrypt -f <encoded-image.png> [-o <output-file.txt>] [--verbose] [--quiet]
87
+ ```
88
+
89
+ **Options:**
90
+ - `-f, --filename`: Path to the PNG image containing the hidden message (required)
91
+ - `-o, --output`: Save decrypted message to a file (optional)
92
+ - `-v, --verbose`: Show detailed progress information
93
+ - `-q, --quiet`: Output only the decrypted message (useful for piping)
94
+
95
+ **Examples:**
96
+ ```bash
97
+ # Display message with nice formatting
98
+ obscr decrypt -f encoded.png
99
+
100
+ # Save to file
101
+ obscr decrypt -f encoded.png -o message.txt
102
+
103
+ # Quiet mode for piping to other commands
104
+ obscr decrypt -f secret.png --quiet | grep "password"
105
+ ```
106
+
107
+ ### Additional Commands
57
108
 
109
+ #### Show Usage Examples
110
+ ```bash
111
+ obscr examples
58
112
  ```
113
+
114
+ Shows comprehensive usage examples with all features.
115
+
116
+ #### Get Help
117
+ ```bash
118
+ obscr --help
119
+ obscr encrypt --help
120
+ obscr decrypt --help
121
+ ```
122
+
123
+ ## How It Works
124
+
125
+ ### Encryption Process
126
+
127
+ 1. **Password Entry**: You enter a password and the message to hide
128
+ 2. **AES-256-GCM Encryption**: The message is encrypted using your password with PBKDF2 key derivation
129
+ 3. **Optional Compression**: If enabled, the encrypted data is compressed with gzip
130
+ 4. **Bit Scrambling**: The encrypted data bits are scrambled using a password-derived seed
131
+ 5. **LSB Steganography**: The scrambled bits are hidden in the least significant bits of the image's RGB channels
132
+ 6. **Output**: A new PNG image is created that looks identical to the original but contains your encrypted message
133
+
134
+ ### Decryption Process
135
+
136
+ 1. **Password Entry**: You enter the same password used for encryption
137
+ 2. **LSB Extraction**: All LSBs are extracted from the image's RGB channels
138
+ 3. **Bit Unscrambling**: The bits are unscrambled using the password-derived seed
139
+ 4. **Decompression**: If the message was compressed, it's automatically decompressed
140
+ 5. **AES-256-GCM Decryption**: The data is decrypted using the password
141
+ 6. **Output**: Your original message is recovered
142
+
143
+ ## Security Properties
144
+
145
+ ### Encryption Layer (AES-256-GCM)
146
+ - **Algorithm**: AES-256 in Galois/Counter Mode
147
+ - **Key Derivation**: PBKDF2 with SHA-512, 65,535 iterations
148
+ - **Authentication**: Built-in authentication tag prevents tampering
149
+ - **Random Salt & Nonce**: Each encryption uses unique random values
150
+
151
+ ### Obfuscation Layer (Steganography)
152
+ - **LSB Technique**: Modifies only the least significant bits, making changes imperceptible
153
+ - **Password-Based Scrambling**: Data bits are scattered in pseudo-random positions
154
+ - **Random Fill**: Unused bits are filled with random values for additional obfuscation
155
+ - **Format**: Standard PNG output, indistinguishable from regular images
156
+
157
+ ### Important Security Notes
158
+
159
+ 1. **Password strength is critical** - Use a strong, unique password
160
+ 2. **Security relies on**:
161
+ - The strength of your password
162
+ - AES-256-GCM encryption (cryptographically secure)
163
+ - PBKDF2 key derivation
164
+ 3. **Limitations**:
165
+ - Steganography provides obfuscation, not security by itself
166
+ - The encrypted image is not resistant to targeted steganalysis by experts
167
+ - If someone knows the image contains a hidden message, they can extract it (but still need your password to decrypt)
168
+
169
+ ## Image Capacity
170
+
171
+ The tool automatically checks if your message fits in the chosen image:
172
+
173
+ - **Capacity**: 3 bits per pixel (RGB channels only)
174
+ - **Example**: A 1920x1080 image can hold ~777 KB of encrypted data
175
+ - **Formula**: `(width × height × 3) / 8 = bytes capacity`
176
+
177
+ If your message is too large:
178
+ 1. Use a larger image
179
+ 2. Enable compression with `--compress`
180
+ 3. Reduce message size
181
+
182
+ The tool will show capacity utilization after successful encryption.
183
+
184
+ ## Installation from Source
185
+
186
+ 1. Clone the repository and navigate to it
187
+ 2. Run `npm install` to install the dependencies
188
+ 3. Run `npm install -g .` to install the CLI globally
189
+
190
+ > :warning: **This might cause an error** which can be resolved easily by using `sudo` with the command, **however**, using `sudo` with `npm` is **not recommended** because it might cause permission issues later. So instead put the code below in your .bashrc file and then run the above command again.
191
+
192
+ ```bash
59
193
  npm set prefix ~/.npm
60
194
  PATH="$HOME/.npm/bin:$PATH"
61
195
  PATH="./node_modules/.bin:$PATH"
62
196
  ```
63
197
 
64
- 4. Now you are good to go and can use the CLI globally!
198
+ 4. Now you can use the CLI globally! Type `obscr` or `obscr --help` to get started.
65
199
 
66
- Type `obscr` or `obscr --help` to get started.
200
+ ## Examples
67
201
 
68
- <br>
202
+ ### Hiding a Secret Note
203
+ ```bash
204
+ obscr encrypt -f vacation.png -o vacation.png
205
+ # Enter password and type your message
206
+ # Result: vacation.png now contains your hidden message
207
+ ```
208
+
209
+ ### Extracting the Secret Note
210
+ ```bash
211
+ obscr decrypt -f vacation.png
212
+ # Enter the same password
213
+ # Your message is displayed
214
+ ```
215
+
216
+ ### Large Message with Compression
217
+ ```bash
218
+ obscr encrypt -f large-photo.png -o secret.png --compress
219
+ # Compression can reduce message size by 50-90% depending on content
220
+ ```
221
+
222
+ ## Backward Compatibility
223
+
224
+ This version maintains full backward compatibility:
225
+ - Can decrypt images created with older versions
226
+ - Automatically detects and handles compressed vs. uncompressed messages
227
+
228
+ ## Technical Details
229
+
230
+ ### File Format
231
+
232
+ Encrypted message format: `salt:nonce:ciphertext:tag[:compressed]`
233
+ - **salt**: 32 bytes (base64) - Random salt for PBKDF2
234
+ - **nonce**: 12 bytes (base64) - Random nonce for AES-GCM
235
+ - **ciphertext**: Variable length (base64) - Encrypted message
236
+ - **tag**: 16 bytes (base64) - GCM authentication tag
237
+ - **compressed**: Optional flag "1" if data was compressed
238
+
239
+ ### Dependencies
240
+ - `crypto` (Node.js built-in): For AES-256-GCM encryption
241
+ - `zlib` (Node.js built-in): For optional compression
242
+ - `pngjs`: For PNG image manipulation
243
+ - `crypto-js`: For SHA-512 hashing
244
+ - `yargs`: For CLI argument parsing
245
+ - `inquirer`: For interactive prompts
246
+ - `chalk`: For colored terminal output
247
+
248
+ > :warning: **Supports only PNG images**
69
249
 
70
250
  ## License
71
251
 
72
252
  MIT © **_Obscr_**
253
+
254
+ ## Author
255
+
256
+ Johannes Dragulanescu
257
+
258
+ ## Contributing
259
+
260
+ Issues and pull requests are welcome at https://github.com/jdragulanescu/obscr