lzo-crypto v1.2.3
LZO: Crypto
Data Encryption and Decryption.
Installation
npm install lzo-crypto OR yarn add lzo-cryptoAttention
The default strategy is
File System, if you want to useRedisyou must call methodCrypto.setStrategy('REDIS').
Configuration
Please input the credentials of your Redis server in the .env file.
See the example in the
.env.examplefile.
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.