https://github.com/matschik/monozip
๐ Utility library and CLI to encrypt/compress and decompress/decrypt zip folders using AES encryption
https://github.com/matschik/monozip
aes-encryption decryption encryption zip
Last synced: 4 months ago
JSON representation
๐ Utility library and CLI to encrypt/compress and decompress/decrypt zip folders using AES encryption
- Host: GitHub
- URL: https://github.com/matschik/monozip
- Owner: matschik
- License: mit
- Created: 2023-07-29T09:11:02.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-17T23:12:39.000Z (over 1 year ago)
- Last Synced: 2025-03-28T11:42:55.874Z (about 1 year ago)
- Topics: aes-encryption, decryption, encryption, zip
- Language: JavaScript
- Homepage:
- Size: 8.27 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Monozip ๐ฆ๐
Utility library providing encrypt/compress and decompress/decrypt using **AES encryption** ๐.
With a simple API, you can easily zip and encrypt a directory and later unzip and decrypt it.
## Features ๐
- Generate encryption keys ๐
- Encrypt and zip folders ๐โก๏ธ๐๐ฆ
- Unzip and decrypt an encrypted zip folder ๐ฆโก๏ธ๐๐
## CLI Usage ๐ป
Monozip can be used directly from the command line. The general structure of a command is:
```bash
monozip [command] [options]
```
### Installation ๐พ
To use the cli, install globally with npm:
```bash
npm install -g monozip
```
### Usage ๐
**To encrypt and zip a folder:**
You can specify an encryption key and an output path using the `-k` and `--output` options respectively. If not specified, a key will be generated automatically, and the output file will be saved in the current directory.
```bash
monozip encrypt ./path/to/folder
```
After running this command, it will print out the encryption key used (keep it safe, you will need it to decrypt ๐), and the path to the zipped file.
**To unzip and decrypt an encrypted zip file:**
You need to provide the encryption key and the path to the zipped file. You can also specify an output path using the `-o` option. If not specified, the file will be unzipped in the current directory.
```bash
monozip decrypt your-key ./path/to/file.zip
```
After running this command, it will print out the path to the unzipped and decrypted files.
## Programmatic Usage ๐ก
### Installation ๐พ
Install the library using npm:
```bash
npm install monozip
```
### Encryption and Compression ๐๐ฆ
To encrypt and zip a folder, you can use the `generateKey` and `encryptAndZipFolder` functions. Here is an example:
```javascript
import { generateKey, encryptAndZipFolder } from "monozip";
const folderPath = "downloads/myphotos";
// Generate a new encryption key
const secretKey = generateKey();
// Encrypt and zip the folder
await encryptAndZipFolder(secretKey, fixtureFolderPath);
console.info(`Encrypted with key ${secretKey} and zipped folder ${folderPath}`);
// Encrypted with key e96c9074fa... and zipped folder downloads/myphotos.zip. Keep the key safe!
```
### Decompression and Decryption ๐๐
To unzip and decrypt a previously encrypted and zipped file, you can use the `unzipAndDecryptZip` function. Here is an example:
```javascript
import { generateKey, unzipAndDecryptZip } from "monozip";
// Assume the encryption key is known
const secretKey = "my-secret-key";
// Unzip and decrypt the zipped file
const zipPath = "downloads/myphotos.zip";
const outputPath = await unzipAndDecryptZip(secretKey, zipPath, {
outputPath: "downloads/myphotos-decrypted",
});
console.info(`Unzipped and decrypted ${outputPath}`);
// Unzipped and decrypted downloads/myphotos-decrypted
```
## Testing ๐งช
The project uses [Vitest](https://github.com/vitest-dev/vitest) for testing.
You can run the tests with:
```bash
npm test
```
## Contributing ๐ค
We welcome contributions! Please see [here](./CONTRIBUTING.md) for details on how to contribute.
## License ๐
This project is open source, licensed under the MIT License. See [LICENSE](./LICENSE) for details.