ecrypto-cli 1.0.7 → 1.0.8
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/README.md +394 -394
- package/bin/ecrypto +2 -2
- package/bin/ecrypto.exe +1 -0
- package/bin/launcher.js +16 -16
- package/package.json +53 -53
- package/postinstall.js +76 -76
package/README.md
CHANGED
|
@@ -1,394 +1,394 @@
|
|
|
1
|
-
# 🔐 ecrypto-cli
|
|
2
|
-
|
|
3
|
-
**Military-Grade Folder & File Encryption Tool**
|
|
4
|
-
|
|
5
|
-
Encrypt entire folders or individual files into secure containers using **XChaCha20-Poly1305** (AEAD) and **Argon2id** (KDF).
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/ecrypto-cli)
|
|
8
|
-
[](https://github.com/pandarudra/ecrypto/blob/main/LICENSE)
|
|
9
|
-
[](https://www.npmjs.com/package/ecrypto-cli)
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## ✨ Features
|
|
14
|
-
|
|
15
|
-
- 🔒 **Military-Grade Encryption**: XChaCha20-Poly1305 AEAD cipher (256-bit keys)
|
|
16
|
-
- 📁 **Folder & File Support**: Encrypt entire folders or individual files
|
|
17
|
-
- 🎨 **Interactive File Browser**: Navigate your file system with arrow keys
|
|
18
|
-
- 🔑 **Flexible Authentication**: Passphrase or raw 32-byte key files
|
|
19
|
-
- 📦 **Single Secure Container**: Compressed + encrypted `.ecrypt` files
|
|
20
|
-
- 🛡️ **Secure by Default**: Argon2id KDF (256MB memory, 3 iterations)
|
|
21
|
-
- ↶ **Undo Feature**: Easily restore recently encrypted data
|
|
22
|
-
- ⚡ **Fast & Lightweight**: Single binary, zero runtime dependencies
|
|
23
|
-
- 🌐 **Cross-Platform**: Windows, macOS, and Linux
|
|
24
|
-
|
|
25
|
-
---
|
|
26
|
-
|
|
27
|
-
## 📥 Installation
|
|
28
|
-
|
|
29
|
-
### Global Installation (Recommended)
|
|
30
|
-
|
|
31
|
-
Install globally to use from anywhere:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install -g ecrypto-cli
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Then use it:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
ecrypto
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Local Installation
|
|
44
|
-
|
|
45
|
-
Install in your project:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
npm install ecrypto-cli
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Run with npx:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
npx ecrypto
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## 🚀 Quick Start
|
|
60
|
-
|
|
61
|
-
### Interactive Mode
|
|
62
|
-
|
|
63
|
-
Launch the interactive menu:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
ecrypto
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
You'll see a beautiful interface:
|
|
70
|
-
|
|
71
|
-
```
|
|
72
|
-
██████ ▄█████ █████▄ ██ ██ █████▄ ██████ ▄████▄
|
|
73
|
-
██▄▄ ██ ██▄▄██▄ ▀██▀ ██▄▄█▀ ██ ██ ██
|
|
74
|
-
██▄▄▄▄ ▀█████ ██ ██ ██ ██ ██ ▀████▀
|
|
75
|
-
|
|
76
|
-
XChaCha20-Poly1305 | Argon2id | Military-Grade Security
|
|
77
|
-
|
|
78
|
-
Main Menu
|
|
79
|
-
───────────
|
|
80
|
-
|
|
81
|
-
> [1] [ENCRYPT] Encrypt a Folder/File
|
|
82
|
-
[2] [DECRYPT] Decrypt a Folder/File
|
|
83
|
-
[3] [KEYGEN] Generate Encryption Key
|
|
84
|
-
[4] [INFO] View Container Info
|
|
85
|
-
[5] [UNDO] Undo Recent Operation
|
|
86
|
-
[6] [EXIT] Quit Application
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Command-Line Mode
|
|
90
|
-
|
|
91
|
-
#### Encrypt a Folder
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# Using a passphrase
|
|
95
|
-
ecrypto encrypt --in ./my-documents --out encrypted.ecrypt --pass
|
|
96
|
-
|
|
97
|
-
# Using a key file
|
|
98
|
-
ecrypto encrypt --in ./my-documents --out encrypted.ecrypt --key-file key.txt
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
#### Encrypt a Single File
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
# Using a passphrase
|
|
105
|
-
ecrypto encrypt --in photo.jpg --out photo.jpg.ecrypt --pass
|
|
106
|
-
|
|
107
|
-
# Using a key file
|
|
108
|
-
ecrypto encrypt --in document.pdf --out document.pdf.ecrypt --key-file key.txt
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
#### Decrypt
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
# Using a passphrase
|
|
115
|
-
ecrypto decrypt --in encrypted.ecrypt --out ./restored --pass
|
|
116
|
-
|
|
117
|
-
# Using a key file
|
|
118
|
-
ecrypto decrypt --in encrypted.ecrypt --out ./restored --key-file key.txt
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
#### Generate Encryption Key
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
ecrypto keygen --out mykey.txt
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
#### View Container Info
|
|
128
|
-
|
|
129
|
-
```bash
|
|
130
|
-
ecrypto info --in encrypted.ecrypt
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## 🎯 Interactive Features
|
|
136
|
-
|
|
137
|
-
### 🗂️ Interactive File Browser
|
|
138
|
-
|
|
139
|
-
No need to type paths manually! Navigate with a visual file browser:
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
💾 Select Drive
|
|
143
|
-
|
|
144
|
-
[1] 💾 C:
|
|
145
|
-
[2] 💾 D:
|
|
146
|
-
|
|
147
|
-
📂 Current: C:\Users\YourName
|
|
148
|
-
|
|
149
|
-
[1] ⬆️ ..
|
|
150
|
-
[2] 📁 Documents
|
|
151
|
-
[3] 📁 Downloads
|
|
152
|
-
[4] 📁 Pictures
|
|
153
|
-
[5] 📄 report.pdf (2.5 MB)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
**Features:**
|
|
157
|
-
|
|
158
|
-
- ✅ Browse drives and folders interactively
|
|
159
|
-
- ✅ See file sizes before selecting
|
|
160
|
-
- ✅ Quick access to common folders
|
|
161
|
-
- ✅ Still supports pasting paths directly
|
|
162
|
-
|
|
163
|
-
### 📋 Smart Path Detection
|
|
164
|
-
|
|
165
|
-
Paste paths directly at any prompt:
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
› Select option: C:\Users\YourName\Documents\MyFolder
|
|
169
|
-
✓ Detected folder: MyFolder
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Works with:
|
|
173
|
-
|
|
174
|
-
- Paths with or without quotes
|
|
175
|
-
- Spaces in names
|
|
176
|
-
- Forward or backward slashes
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## 🔒 Security Features
|
|
181
|
-
|
|
182
|
-
### Encryption
|
|
183
|
-
|
|
184
|
-
- **Cipher**: XChaCha20-Poly1305 (AEAD)
|
|
185
|
-
- 256-bit keys
|
|
186
|
-
- 192-bit nonces (extended nonce space)
|
|
187
|
-
- Authenticated encryption (tamper-proof)
|
|
188
|
-
|
|
189
|
-
### Key Derivation
|
|
190
|
-
|
|
191
|
-
- **KDF**: Argon2id (winner of Password Hashing Competition)
|
|
192
|
-
- Memory: 256 MB
|
|
193
|
-
- Iterations: 3
|
|
194
|
-
- Parallelism: 1
|
|
195
|
-
- Random 128-bit salt per encryption
|
|
196
|
-
|
|
197
|
-
### Container Format
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
[Header 59 bytes] + [Encrypted Data]
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Header includes:
|
|
204
|
-
|
|
205
|
-
- Magic bytes: `ECRYPT01`
|
|
206
|
-
- Version: 1
|
|
207
|
-
- KDF type (0=raw key, 1=Argon2id)
|
|
208
|
-
- Salt (128 bits)
|
|
209
|
-
- Nonce (192 bits)
|
|
210
|
-
- Argon2id parameters
|
|
211
|
-
|
|
212
|
-
---
|
|
213
|
-
|
|
214
|
-
## 📚 Usage Examples
|
|
215
|
-
|
|
216
|
-
### Example 1: Encrypt Personal Documents
|
|
217
|
-
|
|
218
|
-
```bash
|
|
219
|
-
# Interactive mode
|
|
220
|
-
ecrypto
|
|
221
|
-
|
|
222
|
-
# Select [1] Encrypt
|
|
223
|
-
# Choose [1] Browse or paste: ~/Documents/Personal
|
|
224
|
-
# Enter passphrase (hidden input)
|
|
225
|
-
# Done! ✓
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
### Example 2: Batch Encrypt Multiple Files
|
|
229
|
-
|
|
230
|
-
```bash
|
|
231
|
-
# Encrypt each file
|
|
232
|
-
ecrypto encrypt --in file1.txt --out file1.ecrypt --pass
|
|
233
|
-
ecrypto encrypt --in file2.pdf --out file2.ecrypt --pass
|
|
234
|
-
ecrypto encrypt --in file3.jpg --out file3.ecrypt --pass
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Example 3: Generate and Use Key File
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
# Generate key
|
|
241
|
-
ecrypto keygen --out secret.key
|
|
242
|
-
|
|
243
|
-
# Encrypt with key
|
|
244
|
-
ecrypto encrypt --in ./sensitive-data --out backup.ecrypt --key-file secret.key
|
|
245
|
-
|
|
246
|
-
# Later, decrypt with same key
|
|
247
|
-
ecrypto decrypt --in backup.ecrypt --out ./restored --key-file secret.key
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Example 4: Quick Undo
|
|
251
|
-
|
|
252
|
-
```bash
|
|
253
|
-
# In interactive mode
|
|
254
|
-
# Select [5] Undo
|
|
255
|
-
# Shows recent operations
|
|
256
|
-
# Select operation to reverse
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
---
|
|
260
|
-
|
|
261
|
-
## 🔧 Advanced Options
|
|
262
|
-
|
|
263
|
-
### Encryption Options
|
|
264
|
-
|
|
265
|
-
```bash
|
|
266
|
-
ecrypto encrypt \
|
|
267
|
-
--in <folder-or-file> \
|
|
268
|
-
--out <output.ecrypt> \
|
|
269
|
-
--pass # Use passphrase (prompts securely)
|
|
270
|
-
--key-file <key.txt> # Use raw 32-byte key file
|
|
271
|
-
--argon-m <memory-KB> # Argon2id memory (default: 262144 = 256MB)
|
|
272
|
-
--argon-t <iterations> # Argon2id iterations (default: 3)
|
|
273
|
-
--argon-p <parallelism> # Argon2id parallelism (default: 1)
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### Decryption Options
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
ecrypto decrypt \
|
|
280
|
-
--in <encrypted.ecrypt> \
|
|
281
|
-
--out <output-folder> \
|
|
282
|
-
--pass # Use passphrase
|
|
283
|
-
--key-file <key.txt> # Use raw key file
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
---
|
|
287
|
-
|
|
288
|
-
## 🆚 CLI vs Interactive Mode
|
|
289
|
-
|
|
290
|
-
| Feature | CLI Mode | Interactive Mode |
|
|
291
|
-
| ------------ | -------------- | -------------------- |
|
|
292
|
-
| Speed | ⚡ Fastest | 🎨 User-friendly |
|
|
293
|
-
| Automation | ✅ Scriptable | ❌ Manual |
|
|
294
|
-
| File Browser | ❌ Type paths | ✅ Visual navigation |
|
|
295
|
-
| Progress | 📊 Text | 📊 Visual + Icons |
|
|
296
|
-
| Undo | ❌ Manual | ✅ Built-in |
|
|
297
|
-
| Best For | Scripts, CI/CD | Daily use, beginners |
|
|
298
|
-
|
|
299
|
-
---
|
|
300
|
-
|
|
301
|
-
## 🛠️ System Requirements
|
|
302
|
-
|
|
303
|
-
- **Node.js**: 12.x or higher (for npm installation only)
|
|
304
|
-
- **OS**: Windows, macOS, Linux
|
|
305
|
-
- **Disk Space**: ~10 MB
|
|
306
|
-
- **Memory**: Minimum 512 MB RAM (256 MB for Argon2id)
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
|
-
## 🔄 Updates
|
|
311
|
-
|
|
312
|
-
Keep ecrypto-cli up to date:
|
|
313
|
-
|
|
314
|
-
```bash
|
|
315
|
-
# Check current version
|
|
316
|
-
ecrypto --version
|
|
317
|
-
|
|
318
|
-
# Update to latest
|
|
319
|
-
npm update -g ecrypto-cli
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
---
|
|
323
|
-
|
|
324
|
-
## 📖 Documentation
|
|
325
|
-
|
|
326
|
-
Full documentation: [https://github.com/pandarudra/ecrypto](https://github.com/pandarudra/ecrypto)
|
|
327
|
-
|
|
328
|
-
### Help Commands
|
|
329
|
-
|
|
330
|
-
```bash
|
|
331
|
-
ecrypto --help # Show all commands
|
|
332
|
-
ecrypto encrypt --help # Encryption help
|
|
333
|
-
ecrypto decrypt --help # Decryption help
|
|
334
|
-
ecrypto keygen --help # Key generation help
|
|
335
|
-
```
|
|
336
|
-
|
|
337
|
-
---
|
|
338
|
-
|
|
339
|
-
## 🐛 Troubleshooting
|
|
340
|
-
|
|
341
|
-
### Permission Errors
|
|
342
|
-
|
|
343
|
-
**macOS/Linux:**
|
|
344
|
-
|
|
345
|
-
```bash
|
|
346
|
-
sudo npm install -g ecrypto-cli
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
### Binary Not Found
|
|
350
|
-
|
|
351
|
-
**After global install:**
|
|
352
|
-
|
|
353
|
-
```bash
|
|
354
|
-
# Add npm global bin to PATH
|
|
355
|
-
export PATH="$PATH:$(npm config get prefix)/bin"
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
### Old Version Cached
|
|
359
|
-
|
|
360
|
-
```bash
|
|
361
|
-
npm cache clean --force
|
|
362
|
-
npm install -g ecrypto-cli@latest
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
---
|
|
366
|
-
|
|
367
|
-
## 🤝 Contributing
|
|
368
|
-
|
|
369
|
-
Contributions welcome! See [CONTRIBUTING.md](https://github.com/pandarudra/ecrypto/blob/main/CONTRIBUTING.md)
|
|
370
|
-
|
|
371
|
-
---
|
|
372
|
-
|
|
373
|
-
## 📄 License
|
|
374
|
-
|
|
375
|
-
MIT © [pandarudra](https://github.com/pandarudra)
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
## 🔗 Links
|
|
380
|
-
|
|
381
|
-
- **GitHub**: [https://github.com/pandarudra/ecrypto](https://github.com/pandarudra/ecrypto)
|
|
382
|
-
- **Issues**: [https://github.com/pandarudra/ecrypto/issues](https://github.com/pandarudra/ecrypto/issues)
|
|
383
|
-
- **npm**: [https://www.npmjs.com/package/ecrypto-cli](https://www.npmjs.com/package/ecrypto-cli)
|
|
384
|
-
- **Releases**: [https://github.com/pandarudra/ecrypto/releases](https://github.com/pandarudra/ecrypto/releases)
|
|
385
|
-
|
|
386
|
-
---
|
|
387
|
-
|
|
388
|
-
<div align="center">
|
|
389
|
-
|
|
390
|
-
**Made with ❤️ for Privacy & Security**
|
|
391
|
-
|
|
392
|
-
⭐ Star us on GitHub if you find this useful!
|
|
393
|
-
|
|
394
|
-
</div>
|
|
1
|
+
# 🔐 ecrypto-cli
|
|
2
|
+
|
|
3
|
+
**Military-Grade Folder & File Encryption Tool**
|
|
4
|
+
|
|
5
|
+
Encrypt entire folders or individual files into secure containers using **XChaCha20-Poly1305** (AEAD) and **Argon2id** (KDF).
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/ecrypto-cli)
|
|
8
|
+
[](https://github.com/pandarudra/ecrypto/blob/main/LICENSE)
|
|
9
|
+
[](https://www.npmjs.com/package/ecrypto-cli)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## ✨ Features
|
|
14
|
+
|
|
15
|
+
- 🔒 **Military-Grade Encryption**: XChaCha20-Poly1305 AEAD cipher (256-bit keys)
|
|
16
|
+
- 📁 **Folder & File Support**: Encrypt entire folders or individual files
|
|
17
|
+
- 🎨 **Interactive File Browser**: Navigate your file system with arrow keys
|
|
18
|
+
- 🔑 **Flexible Authentication**: Passphrase or raw 32-byte key files
|
|
19
|
+
- 📦 **Single Secure Container**: Compressed + encrypted `.ecrypt` files
|
|
20
|
+
- 🛡️ **Secure by Default**: Argon2id KDF (256MB memory, 3 iterations)
|
|
21
|
+
- ↶ **Undo Feature**: Easily restore recently encrypted data
|
|
22
|
+
- ⚡ **Fast & Lightweight**: Single binary, zero runtime dependencies
|
|
23
|
+
- 🌐 **Cross-Platform**: Windows, macOS, and Linux
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📥 Installation
|
|
28
|
+
|
|
29
|
+
### Global Installation (Recommended)
|
|
30
|
+
|
|
31
|
+
Install globally to use from anywhere:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g ecrypto-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then use it:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
ecrypto
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Local Installation
|
|
44
|
+
|
|
45
|
+
Install in your project:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install ecrypto-cli
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Run with npx:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx ecrypto
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 🚀 Quick Start
|
|
60
|
+
|
|
61
|
+
### Interactive Mode
|
|
62
|
+
|
|
63
|
+
Launch the interactive menu:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
ecrypto
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
You'll see a beautiful interface:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
██████ ▄█████ █████▄ ██ ██ █████▄ ██████ ▄████▄
|
|
73
|
+
██▄▄ ██ ██▄▄██▄ ▀██▀ ██▄▄█▀ ██ ██ ██
|
|
74
|
+
██▄▄▄▄ ▀█████ ██ ██ ██ ██ ██ ▀████▀
|
|
75
|
+
|
|
76
|
+
XChaCha20-Poly1305 | Argon2id | Military-Grade Security
|
|
77
|
+
|
|
78
|
+
Main Menu
|
|
79
|
+
───────────
|
|
80
|
+
|
|
81
|
+
> [1] [ENCRYPT] Encrypt a Folder/File
|
|
82
|
+
[2] [DECRYPT] Decrypt a Folder/File
|
|
83
|
+
[3] [KEYGEN] Generate Encryption Key
|
|
84
|
+
[4] [INFO] View Container Info
|
|
85
|
+
[5] [UNDO] Undo Recent Operation
|
|
86
|
+
[6] [EXIT] Quit Application
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Command-Line Mode
|
|
90
|
+
|
|
91
|
+
#### Encrypt a Folder
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Using a passphrase
|
|
95
|
+
ecrypto encrypt --in ./my-documents --out encrypted.ecrypt --pass
|
|
96
|
+
|
|
97
|
+
# Using a key file
|
|
98
|
+
ecrypto encrypt --in ./my-documents --out encrypted.ecrypt --key-file key.txt
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### Encrypt a Single File
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Using a passphrase
|
|
105
|
+
ecrypto encrypt --in photo.jpg --out photo.jpg.ecrypt --pass
|
|
106
|
+
|
|
107
|
+
# Using a key file
|
|
108
|
+
ecrypto encrypt --in document.pdf --out document.pdf.ecrypt --key-file key.txt
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Decrypt
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Using a passphrase
|
|
115
|
+
ecrypto decrypt --in encrypted.ecrypt --out ./restored --pass
|
|
116
|
+
|
|
117
|
+
# Using a key file
|
|
118
|
+
ecrypto decrypt --in encrypted.ecrypt --out ./restored --key-file key.txt
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Generate Encryption Key
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
ecrypto keygen --out mykey.txt
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### View Container Info
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
ecrypto info --in encrypted.ecrypt
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🎯 Interactive Features
|
|
136
|
+
|
|
137
|
+
### 🗂️ Interactive File Browser
|
|
138
|
+
|
|
139
|
+
No need to type paths manually! Navigate with a visual file browser:
|
|
140
|
+
|
|
141
|
+
```
|
|
142
|
+
💾 Select Drive
|
|
143
|
+
|
|
144
|
+
[1] 💾 C:
|
|
145
|
+
[2] 💾 D:
|
|
146
|
+
|
|
147
|
+
📂 Current: C:\Users\YourName
|
|
148
|
+
|
|
149
|
+
[1] ⬆️ ..
|
|
150
|
+
[2] 📁 Documents
|
|
151
|
+
[3] 📁 Downloads
|
|
152
|
+
[4] 📁 Pictures
|
|
153
|
+
[5] 📄 report.pdf (2.5 MB)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Features:**
|
|
157
|
+
|
|
158
|
+
- ✅ Browse drives and folders interactively
|
|
159
|
+
- ✅ See file sizes before selecting
|
|
160
|
+
- ✅ Quick access to common folders
|
|
161
|
+
- ✅ Still supports pasting paths directly
|
|
162
|
+
|
|
163
|
+
### 📋 Smart Path Detection
|
|
164
|
+
|
|
165
|
+
Paste paths directly at any prompt:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
› Select option: C:\Users\YourName\Documents\MyFolder
|
|
169
|
+
✓ Detected folder: MyFolder
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Works with:
|
|
173
|
+
|
|
174
|
+
- Paths with or without quotes
|
|
175
|
+
- Spaces in names
|
|
176
|
+
- Forward or backward slashes
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 🔒 Security Features
|
|
181
|
+
|
|
182
|
+
### Encryption
|
|
183
|
+
|
|
184
|
+
- **Cipher**: XChaCha20-Poly1305 (AEAD)
|
|
185
|
+
- 256-bit keys
|
|
186
|
+
- 192-bit nonces (extended nonce space)
|
|
187
|
+
- Authenticated encryption (tamper-proof)
|
|
188
|
+
|
|
189
|
+
### Key Derivation
|
|
190
|
+
|
|
191
|
+
- **KDF**: Argon2id (winner of Password Hashing Competition)
|
|
192
|
+
- Memory: 256 MB
|
|
193
|
+
- Iterations: 3
|
|
194
|
+
- Parallelism: 1
|
|
195
|
+
- Random 128-bit salt per encryption
|
|
196
|
+
|
|
197
|
+
### Container Format
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
[Header 59 bytes] + [Encrypted Data]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Header includes:
|
|
204
|
+
|
|
205
|
+
- Magic bytes: `ECRYPT01`
|
|
206
|
+
- Version: 1
|
|
207
|
+
- KDF type (0=raw key, 1=Argon2id)
|
|
208
|
+
- Salt (128 bits)
|
|
209
|
+
- Nonce (192 bits)
|
|
210
|
+
- Argon2id parameters
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 📚 Usage Examples
|
|
215
|
+
|
|
216
|
+
### Example 1: Encrypt Personal Documents
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Interactive mode
|
|
220
|
+
ecrypto
|
|
221
|
+
|
|
222
|
+
# Select [1] Encrypt
|
|
223
|
+
# Choose [1] Browse or paste: ~/Documents/Personal
|
|
224
|
+
# Enter passphrase (hidden input)
|
|
225
|
+
# Done! ✓
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Example 2: Batch Encrypt Multiple Files
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
# Encrypt each file
|
|
232
|
+
ecrypto encrypt --in file1.txt --out file1.ecrypt --pass
|
|
233
|
+
ecrypto encrypt --in file2.pdf --out file2.ecrypt --pass
|
|
234
|
+
ecrypto encrypt --in file3.jpg --out file3.ecrypt --pass
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Example 3: Generate and Use Key File
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Generate key
|
|
241
|
+
ecrypto keygen --out secret.key
|
|
242
|
+
|
|
243
|
+
# Encrypt with key
|
|
244
|
+
ecrypto encrypt --in ./sensitive-data --out backup.ecrypt --key-file secret.key
|
|
245
|
+
|
|
246
|
+
# Later, decrypt with same key
|
|
247
|
+
ecrypto decrypt --in backup.ecrypt --out ./restored --key-file secret.key
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Example 4: Quick Undo
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
# In interactive mode
|
|
254
|
+
# Select [5] Undo
|
|
255
|
+
# Shows recent operations
|
|
256
|
+
# Select operation to reverse
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 🔧 Advanced Options
|
|
262
|
+
|
|
263
|
+
### Encryption Options
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
ecrypto encrypt \
|
|
267
|
+
--in <folder-or-file> \
|
|
268
|
+
--out <output.ecrypt> \
|
|
269
|
+
--pass # Use passphrase (prompts securely)
|
|
270
|
+
--key-file <key.txt> # Use raw 32-byte key file
|
|
271
|
+
--argon-m <memory-KB> # Argon2id memory (default: 262144 = 256MB)
|
|
272
|
+
--argon-t <iterations> # Argon2id iterations (default: 3)
|
|
273
|
+
--argon-p <parallelism> # Argon2id parallelism (default: 1)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Decryption Options
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
ecrypto decrypt \
|
|
280
|
+
--in <encrypted.ecrypt> \
|
|
281
|
+
--out <output-folder> \
|
|
282
|
+
--pass # Use passphrase
|
|
283
|
+
--key-file <key.txt> # Use raw key file
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 🆚 CLI vs Interactive Mode
|
|
289
|
+
|
|
290
|
+
| Feature | CLI Mode | Interactive Mode |
|
|
291
|
+
| ------------ | -------------- | -------------------- |
|
|
292
|
+
| Speed | ⚡ Fastest | 🎨 User-friendly |
|
|
293
|
+
| Automation | ✅ Scriptable | ❌ Manual |
|
|
294
|
+
| File Browser | ❌ Type paths | ✅ Visual navigation |
|
|
295
|
+
| Progress | 📊 Text | 📊 Visual + Icons |
|
|
296
|
+
| Undo | ❌ Manual | ✅ Built-in |
|
|
297
|
+
| Best For | Scripts, CI/CD | Daily use, beginners |
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 🛠️ System Requirements
|
|
302
|
+
|
|
303
|
+
- **Node.js**: 12.x or higher (for npm installation only)
|
|
304
|
+
- **OS**: Windows, macOS, Linux
|
|
305
|
+
- **Disk Space**: ~10 MB
|
|
306
|
+
- **Memory**: Minimum 512 MB RAM (256 MB for Argon2id)
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 🔄 Updates
|
|
311
|
+
|
|
312
|
+
Keep ecrypto-cli up to date:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
# Check current version
|
|
316
|
+
ecrypto --version
|
|
317
|
+
|
|
318
|
+
# Update to latest
|
|
319
|
+
npm update -g ecrypto-cli
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 📖 Documentation
|
|
325
|
+
|
|
326
|
+
Full documentation: [https://github.com/pandarudra/ecrypto](https://github.com/pandarudra/ecrypto)
|
|
327
|
+
|
|
328
|
+
### Help Commands
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
ecrypto --help # Show all commands
|
|
332
|
+
ecrypto encrypt --help # Encryption help
|
|
333
|
+
ecrypto decrypt --help # Decryption help
|
|
334
|
+
ecrypto keygen --help # Key generation help
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 🐛 Troubleshooting
|
|
340
|
+
|
|
341
|
+
### Permission Errors
|
|
342
|
+
|
|
343
|
+
**macOS/Linux:**
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
sudo npm install -g ecrypto-cli
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Binary Not Found
|
|
350
|
+
|
|
351
|
+
**After global install:**
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
# Add npm global bin to PATH
|
|
355
|
+
export PATH="$PATH:$(npm config get prefix)/bin"
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### Old Version Cached
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
npm cache clean --force
|
|
362
|
+
npm install -g ecrypto-cli@latest
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## 🤝 Contributing
|
|
368
|
+
|
|
369
|
+
Contributions welcome! See [CONTRIBUTING.md](https://github.com/pandarudra/ecrypto/blob/main/CONTRIBUTING.md)
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## 📄 License
|
|
374
|
+
|
|
375
|
+
MIT © [pandarudra](https://github.com/pandarudra)
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## 🔗 Links
|
|
380
|
+
|
|
381
|
+
- **GitHub**: [https://github.com/pandarudra/ecrypto](https://github.com/pandarudra/ecrypto)
|
|
382
|
+
- **Issues**: [https://github.com/pandarudra/ecrypto/issues](https://github.com/pandarudra/ecrypto/issues)
|
|
383
|
+
- **npm**: [https://www.npmjs.com/package/ecrypto-cli](https://www.npmjs.com/package/ecrypto-cli)
|
|
384
|
+
- **Releases**: [https://github.com/pandarudra/ecrypto/releases](https://github.com/pandarudra/ecrypto/releases)
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
<div align="center">
|
|
389
|
+
|
|
390
|
+
**Made with ❤️ for Privacy & Security**
|
|
391
|
+
|
|
392
|
+
⭐ Star us on GitHub if you find this useful!
|
|
393
|
+
|
|
394
|
+
</div>
|
package/bin/ecrypto
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
echo "ECRYPTO installing binary..."
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
echo "ECRYPTO installing binary..."
|
package/bin/ecrypto.exe
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ECRYPTO installing...
|
package/bin/launcher.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const { spawn } = require("child_process");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const os = require("os");
|
|
6
|
-
|
|
7
|
-
const platform = os.platform();
|
|
8
|
-
const binary = platform === "win32" ? "ecrypto.exe" : "ecrypto";
|
|
9
|
-
|
|
10
|
-
const binPath = path.join(__dirname, binary);
|
|
11
|
-
|
|
12
|
-
const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
13
|
-
|
|
14
|
-
child.on("exit", (code) => {
|
|
15
|
-
process.exit(code);
|
|
16
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawn } = require("child_process");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const os = require("os");
|
|
6
|
+
|
|
7
|
+
const platform = os.platform();
|
|
8
|
+
const binary = platform === "win32" ? "ecrypto.exe" : "ecrypto";
|
|
9
|
+
|
|
10
|
+
const binPath = path.join(__dirname, binary);
|
|
11
|
+
|
|
12
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
13
|
+
|
|
14
|
+
child.on("exit", (code) => {
|
|
15
|
+
process.exit(code);
|
|
16
|
+
});
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ecrypto-cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Military-grade folder & file encryption tool with XChaCha20-Poly1305 and Argon2id. Interactive file browser, cross-platform CLI.",
|
|
5
|
-
"bin": {
|
|
6
|
-
"ecrypto": "bin/launcher.js",
|
|
7
|
-
"ecrypto-cli": "bin/launcher.js"
|
|
8
|
-
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"postinstall": "node postinstall.js"
|
|
11
|
-
},
|
|
12
|
-
"files": [
|
|
13
|
-
"bin/",
|
|
14
|
-
"postinstall.js",
|
|
15
|
-
"README.md"
|
|
16
|
-
],
|
|
17
|
-
"os": [
|
|
18
|
-
"darwin",
|
|
19
|
-
"linux",
|
|
20
|
-
"win32"
|
|
21
|
-
],
|
|
22
|
-
"homepage": "https://github.com/pandarudra/ecrypto",
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/pandarudra/ecrypto.git"
|
|
26
|
-
},
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/pandarudra/ecrypto/issues"
|
|
29
|
-
},
|
|
30
|
-
"keywords": [
|
|
31
|
-
"encryption",
|
|
32
|
-
"crypto",
|
|
33
|
-
"security",
|
|
34
|
-
"cli",
|
|
35
|
-
"xchacha20",
|
|
36
|
-
"poly1305",
|
|
37
|
-
"argon2id",
|
|
38
|
-
"aead",
|
|
39
|
-
"folder-encryption",
|
|
40
|
-
"file-encryption",
|
|
41
|
-
"military-grade",
|
|
42
|
-
"privacy",
|
|
43
|
-
"secure",
|
|
44
|
-
"cross-platform",
|
|
45
|
-
"interactive",
|
|
46
|
-
"file-browser"
|
|
47
|
-
],
|
|
48
|
-
"author": "pandarudra",
|
|
49
|
-
"license": "MIT",
|
|
50
|
-
"engines": {
|
|
51
|
-
"node": ">=12.0.0"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ecrypto-cli",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"description": "Military-grade folder & file encryption tool with XChaCha20-Poly1305 and Argon2id. Interactive file browser, cross-platform CLI.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"ecrypto": "bin/launcher.js",
|
|
7
|
+
"ecrypto-cli": "bin/launcher.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"postinstall": "node postinstall.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"postinstall.js",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"os": [
|
|
18
|
+
"darwin",
|
|
19
|
+
"linux",
|
|
20
|
+
"win32"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://github.com/pandarudra/ecrypto",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/pandarudra/ecrypto.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/pandarudra/ecrypto/issues"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"encryption",
|
|
32
|
+
"crypto",
|
|
33
|
+
"security",
|
|
34
|
+
"cli",
|
|
35
|
+
"xchacha20",
|
|
36
|
+
"poly1305",
|
|
37
|
+
"argon2id",
|
|
38
|
+
"aead",
|
|
39
|
+
"folder-encryption",
|
|
40
|
+
"file-encryption",
|
|
41
|
+
"military-grade",
|
|
42
|
+
"privacy",
|
|
43
|
+
"secure",
|
|
44
|
+
"cross-platform",
|
|
45
|
+
"interactive",
|
|
46
|
+
"file-browser"
|
|
47
|
+
],
|
|
48
|
+
"author": "pandarudra",
|
|
49
|
+
"license": "MIT",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=12.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/postinstall.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const os = require("os");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const https = require("https");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
|
|
8
|
-
const version = "v1.0.7";
|
|
9
|
-
|
|
10
|
-
function getBinaryName() {
|
|
11
|
-
const platform = os.platform();
|
|
12
|
-
const arch = os.arch();
|
|
13
|
-
|
|
14
|
-
const archMap = {
|
|
15
|
-
x64: "amd64",
|
|
16
|
-
arm64: "arm64",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const platformMap = {
|
|
20
|
-
win32: "windows",
|
|
21
|
-
darwin: "darwin",
|
|
22
|
-
linux: "linux",
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const goos = platformMap[platform];
|
|
26
|
-
const goarch = archMap[arch];
|
|
27
|
-
|
|
28
|
-
if (!goos || !goarch) {
|
|
29
|
-
console.error(`Unsupported platform or architecture: ${platform} ${arch}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return goos === "windows"
|
|
35
|
-
? `ecrypto-${goos}-${goarch}.exe`
|
|
36
|
-
: `ecrypto-${goos}-${goarch}`;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function download(url, dest, cb) {
|
|
40
|
-
https.get(url, (res) => {
|
|
41
|
-
// Follow redirects
|
|
42
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
43
|
-
return download(res.headers.location, dest, cb);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (res.statusCode !== 200) {
|
|
47
|
-
console.error("❌ Failed to download:", res.statusCode, url);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const file = fs.createWriteStream(dest);
|
|
52
|
-
res.pipe(file);
|
|
53
|
-
|
|
54
|
-
file.on("finish", () => file.close(cb));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const fileName = getBinaryName();
|
|
59
|
-
const downloadUrl = `https://github.com/pandarudra/ecrypto/releases/download/${version}/${fileName}`;
|
|
60
|
-
|
|
61
|
-
console.log(`⬇️ Downloading ECRYPTO binary: ${downloadUrl}`);
|
|
62
|
-
|
|
63
|
-
// bin folder should be inside npm/ folder
|
|
64
|
-
const binDir = path.join(__dirname, "bin");
|
|
65
|
-
const binaryName = os.platform() === "win32" ? "ecrypto.exe" : "ecrypto";
|
|
66
|
-
const outputPath = path.join(binDir, binaryName);
|
|
67
|
-
|
|
68
|
-
// Ensure bin/ exists
|
|
69
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
70
|
-
|
|
71
|
-
download(downloadUrl, outputPath, () => {
|
|
72
|
-
if (os.platform() !== "win32") {
|
|
73
|
-
fs.chmodSync(outputPath, 0o755);
|
|
74
|
-
}
|
|
75
|
-
console.log("✅ ECRYPTO installed successfully.");
|
|
76
|
-
});
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const os = require("os");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const https = require("https");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
const version = "v1.0.7";
|
|
9
|
+
|
|
10
|
+
function getBinaryName() {
|
|
11
|
+
const platform = os.platform();
|
|
12
|
+
const arch = os.arch();
|
|
13
|
+
|
|
14
|
+
const archMap = {
|
|
15
|
+
x64: "amd64",
|
|
16
|
+
arm64: "arm64",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const platformMap = {
|
|
20
|
+
win32: "windows",
|
|
21
|
+
darwin: "darwin",
|
|
22
|
+
linux: "linux",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const goos = platformMap[platform];
|
|
26
|
+
const goarch = archMap[arch];
|
|
27
|
+
|
|
28
|
+
if (!goos || !goarch) {
|
|
29
|
+
console.error(`Unsupported platform or architecture: ${platform} ${arch}`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return goos === "windows"
|
|
35
|
+
? `ecrypto-${goos}-${goarch}.exe`
|
|
36
|
+
: `ecrypto-${goos}-${goarch}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function download(url, dest, cb) {
|
|
40
|
+
https.get(url, (res) => {
|
|
41
|
+
// Follow redirects
|
|
42
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
43
|
+
return download(res.headers.location, dest, cb);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (res.statusCode !== 200) {
|
|
47
|
+
console.error("❌ Failed to download:", res.statusCode, url);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const file = fs.createWriteStream(dest);
|
|
52
|
+
res.pipe(file);
|
|
53
|
+
|
|
54
|
+
file.on("finish", () => file.close(cb));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fileName = getBinaryName();
|
|
59
|
+
const downloadUrl = `https://github.com/pandarudra/ecrypto/releases/download/${version}/${fileName}`;
|
|
60
|
+
|
|
61
|
+
console.log(`⬇️ Downloading ECRYPTO binary: ${downloadUrl}`);
|
|
62
|
+
|
|
63
|
+
// bin folder should be inside npm/ folder
|
|
64
|
+
const binDir = path.join(__dirname, "bin");
|
|
65
|
+
const binaryName = os.platform() === "win32" ? "ecrypto.exe" : "ecrypto";
|
|
66
|
+
const outputPath = path.join(binDir, binaryName);
|
|
67
|
+
|
|
68
|
+
// Ensure bin/ exists
|
|
69
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
70
|
+
|
|
71
|
+
download(downloadUrl, outputPath, () => {
|
|
72
|
+
if (os.platform() !== "win32") {
|
|
73
|
+
fs.chmodSync(outputPath, 0o755);
|
|
74
|
+
}
|
|
75
|
+
console.log("✅ ECRYPTO installed successfully.");
|
|
76
|
+
});
|