Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scrwdrv/folder-encrypt
Simple module that helps you encrypt & decrypt folder with password.
https://github.com/scrwdrv/folder-encrypt
aes aes-encryption decryption directory encryption folder fs promise tar typescript
Last synced: about 1 month ago
JSON representation
Simple module that helps you encrypt & decrypt folder with password.
- Host: GitHub
- URL: https://github.com/scrwdrv/folder-encrypt
- Owner: scrwdrv
- License: mit
- Created: 2020-01-12T05:48:51.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-02T17:09:57.000Z (about 4 years ago)
- Last Synced: 2024-09-19T01:13:26.835Z (about 2 months ago)
- Topics: aes, aes-encryption, decryption, directory, encryption, folder, fs, promise, tar, typescript
- Language: TypeScript
- Size: 1.16 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# folder-encrypt
Simple module that helps you encrypt & decrypt folder/file with password.## Installation
```sh
npm i folder-encrypt
```## Usage
Both methods (```encrypt```, ```decrypt```) of folder-encrypt use Promise, and it will automatically detect whether this path is a file or directory.### Folder/File Encryption
```js
import * as folderEncrypt from 'folder-encrypt';folderEncrypt.encrypt({
password: 'your-password',
input: 'your-file-or-folder',
output: 'your-file-or-folder.encrypted' // optional, default will be input path with extension `encrypted`
}).then(() => {
console.log('encrypted!');
}).catch((err) => {
console.log(err);
});
```#### Stream as Output
```js
import * as folderEncrypt from 'folder-encrypt';
import { Writable } from 'stream';
import * as fs from 'fs';const outputs = [
fs.createWriteStream('./output1'),
fs.createWriteStream('./output2')
], writeStream = new Writable({
write(chunk, encoding, next) {
for (let i = outputs.length; i--;) outputs[i].write(chunk);
next();
}
});folderEncrypt.encrypt({
password: 'your-password',
input: 'your-file-or-folder',
output: writeStream // writable stream
}).then(() => {
console.log('encrypted!');
}).catch((err) => {
console.log(err)
});
```
### Folder/File Decryption
```js
folderEncrypt.decrypt({
password: 'your-password',
input: 'your-file-or-folder.encrypted',
output: 'your-file-or-folder' // optional, default will be input path without extension
}).then(() => {
console.log('decrypted!');
// when using a wrong password on file decryption, the file will be decrypted to a bunch of garbled text.
// But still considered `decrypted` due to there is no way knowing the original content.
}).catch((err) => {
console.log(err);
// when using a wrong password on directory decryption, a `tar is corrupted` error will occured.
});
```