@ibnlanre/cipher
v2.3.0
Published
Library for AES encryption or decryption
Downloads
106
Maintainers
Readme
@ibnlanre/cipher
for AES encryption or decryption
Install
To use, you'll need to install Node and Yarn or npm
NPM
npm i @ibnlanre/cipher
YARN
yarn add @ibnlanre/cipher
Import
ES6 Import
import Cipher from "@ibnlanre/cipher";
NodeJS Require
const Cipher = require("@ibnlanre/cipher").default;
Usage
Instantiate
const encryption_key = Cipher.generateRandomKey(256); const initialization_vector = Cipher.generateRandomKey(128); const cipher = new Cipher({ initialization_vector, algorithm: "aes-256-cbc", output_decoding: "base64", input_encoding: "utf-8", encryption_key, });
Destructure
const { encrypt, decrypt } = cipher;
Utilize
const formData = { example: "fooBar" }; const encryptedData = encrypt(formData); const decryptedData = decrypt(encryptedData);