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

1.2.3 • Public • Published

LZO: Crypto

Data Encryption and Decryption.

Sponsor Commitizen friendly TypeScript version Node.js version MIT Build Status - GitHub Actions

Installation

npm install lzo-crypto OR yarn add lzo-crypto

Attention

The default strategy is File System, if you want to use Redis you must call method Crypto.setStrategy('REDIS').

Configuration

Please input the credentials of your Redis server in the .env file.

See the example in the .env.example file.

REDIS_URL="redis://IP:PORT"
REDIS_PORT=6379
REDIS_PASSWORD="PASSWORD"

Usage

import { Crypto } from 'lzo-crypto';

const encrypted = await crypto.encrypt(
  'I have always feed my dog the dog food that comes in the big green bag.',
);

const decrypted = await crypto.decrypt(encrypted);

console.log(encrypted); // 77b3e7c6e42c057dac9809ac3513b519026af5e6cfb33dbb6
console.log(decrypted); // I have always feed my dog the dog food that comes in the big green bag.

API

Crypto.setStrategy(strategy: Strategy): void

Define the strategy to use for storage and retrieval of the IV and tag

Crypto.encrypt(txt: string, password?: string): Promise<string>

It encrypts a string using a password and saves the encrypted string, the initialization vector, and the authentication tag to the database

Crypto.decrypt(encrypted: string, password?: string, del?: boolean): Promise<string>

It decrypts the encrypted string using the password and the IV and the tag

Backers & Sponsors

Support this project by becoming a sponsor.

License

Licensed under the MIT. See the LICENSE file for details.

Package Sidebar

Install

npm i lzo-crypto

Weekly Downloads

1

Version

1.2.3

License

MIT

Unpacked Size

17.3 kB

Total Files

5

Last publish

Collaborators

  • guilhermesantos001