Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bjarneo/node-encryption
Encrypt and decryption
https://github.com/bjarneo/node-encryption
Last synced: 3 days ago
JSON representation
Encrypt and decryption
- Host: GitHub
- URL: https://github.com/bjarneo/node-encryption
- Owner: bjarneo
- License: mit
- Created: 2021-10-07T16:39:41.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-10T07:59:36.000Z (6 months ago)
- Last Synced: 2024-10-14T07:56:51.716Z (about 1 month ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-encryption
This package will simplify the process of encrypting and decrypting data for your application providing robust AES-256-GCM encryption and decryption utilities for protecting sensitive data.
```bash
$ npm install --save node-encryption
```### How to use this package
```javascript
import { encrypt, decrypt } from 'node-encryption';const text = 'This will be encrypted';
const encryptionKey = 'mysecretkey1337';const encrypted = encrypt(text, encryptionKey);
const decrypted = decrypt(encrypted, encryptionKey);
console.log(decrypted.toString());
// Output: This will be encrypted// By using a buffer
const encryptBuffer = encrypt(Buffer.from(text), encryptionKey);const decryptBuffer = decrypt(encryptBuffer, encryptionKey);
console.log(decryptBuffer.toString());
// Output: This will be encrypted
```### How to encrypt & decrypt a file
```javascript
const image = fs.readFileSync('./shyguy.png');const encryptionKey = 'mysecretkey1337';
const encrypted = encrypt(image, encryptionKey);
const decrytedImageBuffer = decrypt(encrypted, encryptionKey);
```### Development
```bash
$ npm install
$ npm test
```### License
MIT - see LICENSE