@nroot_project/ncrypt
v1.1.2
Published
Fast, secure binary file/directory encryption and compression for Node.js. Supports AES-256-GCM, ChaCha20-Poly1305, and 6 compression methods.
Maintainers
Readme
ncrypt
Fast, secure binary file/directory encryption and compression CLI + library for Node.js.
Features
- Authenticated Encryption - AES-256-GCM, AES-128-GCM, ChaCha20-Poly1305
- 6 Compression Methods - zstd, lz4, brotli, gzip, xz (LZMA), none
- Files & Directories - Single files or full directory trees via NArchive
- Strong KDF - PBKDF2 with 100,000 iterations and random salts
- MessagePack - Compact binary container format
- CLI + Programmatic - Interactive CLI or use as a library
- Zero Temp Files - Everything streams through memory
Installation
npm install @nroot_project/ncryptCLI Usage
# Pack (encrypt) a file or directory
ncrypt pack ./my-folder
ncrypt pack ./myfile.txt
# Unpack (decrypt) a .ncrypt file
ncrypt unpack ./my-folder.ncryptOptions
ncrypt pack [source] [options]
Options:
-a, --algo <algorithm> Encryption algorithm (aes-256-gcm, chacha20-poly1305, aes-128-gcm)
-c, --compression <method> Compression method (zstd, lz4, brotli, gzip, xz, none)
-l, --level <1-15> Compression level
-p, --password <password> Password
-o, --output <path> Output pathncrypt unpack [file] [options]
Options:
-p, --password <password> Password
-o, --output <path> Output directoryProgrammatic API
import {
runInteractivePack,
runInteractiveUnpack,
encryptAndSave,
decryptAndExtract,
} from "@nroot_project/ncrypt";encryptAndSave(sourcePath, outputPath, algo, compression, level, passphrase)
Encrypts a file or directory and writes a .ncrypt container.
await encryptAndSave(
"./my-folder", // file or directory
"./output.ncrypt", // output path
"aes-256-gcm", // encryption algorithm
"zstd", // compression method
6, // compression level (1-15)
"my-secure-password", // passphrase
);decryptAndExtract(filePath, outputPath, passphrase)
Decrypts a .ncrypt file and extracts its contents.
await decryptAndExtract(
"./output.ncrypt", // .ncrypt file path
"./extracted", // output path (file or directory)
"my-secure-password", // passphrase
);runInteractivePack(source?, options?)
Interactive CLI pack wizard with prompts for all options.
await runInteractivePack("./my-folder", {
algo: "aes-256-gcm",
compression: "zstd",
level: 6,
password: "secret",
output: "./output.ncrypt",
});runInteractiveUnpack(file?, options?)
Interactive CLI unpack wizard.
await runInteractiveUnpack("./output.ncrypt", {
password: "secret",
output: "./extracted",
});Supported Algorithms
| Category | Options |
|---|---|
| Encryption | aes-256-gcm (default), aes-128-gcm, chacha20-poly1305 |
| Compression | zstd (default), lz4, brotli, gzip, xz, none |
| KDF | PBKDF2-SHA256 (100,000 iterations) |
| Serialization | MessagePack |
Compression Levels
| Algorithm | Level Range | Default | |---|---|---| | gzip | 1 - 9 | 4 | | brotli | 1 - 11 | 4 | | zstd | 1 - 15 | 6 | | lz4 | (fixed) | - | | xz | 0 - 9 | 6 |
Companion Package
NArchive - high-performance directory archiving used internally for directory packing.
npm install @nroot_project/narchiveLicense
MIT - see LICENSE.
