cryptmanager
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha1 • Public • Published

CryptManager

NPM Software License npm npm GitHub actions state

A simple encryption/decryption manager for storing sensitive data using the Node.JS crypto module.

Installation

npm install cryptmanager
yarn add cryptmanager
pnpm add cryptmanager

Usage

import createCryptManager from 'cryptmanager';

const cryptManager = createCryptManager();

Encrypt/Decrypt a string

const encryptedString = await cryptManager.encryptString('Hello World'); // Output: base64 string
const decryptedString = await cryptManager.decryptString(encryptedString); // Output: Hello World

Encrypt/Decrypt a buffer object (e.g. a file)

const buffer = Buffer.from(fs.readFileSync('./test.txt'));

const encryptedBuffer = await cryptManager.encrypt(buffer);
const decryptedBuffer = await cryptManager.decrypt(encryptedBuffer);

Encrypt/Decrypt a JSON object

const myObject = {
  hello: 'world',
};
const objectBuffer = Buffer.from(JSON.stringify(myObject));
const encryptedJSON = await cryptManager.encrypt(objectBuffer); // Output: Buffer

const decryptedBuffer = await cryptManager.decrypt(encryptedJSON);
const decryptedObject = JSON.parse(decryptedBuffer.toString('utf8')); // Output: Object

Readme

Keywords

none

Package Sidebar

Install

npm i cryptmanager

Weekly Downloads

0

Version

0.0.1-alpha1

License

MIT

Unpacked Size

24 kB

Total Files

9

Last publish

Collaborators

  • sierrajc