aes256cbc-enc
v1.0.9
Published
simple aes-256-cbc encryption utilities
Downloads
20
Readme
AES 256 CBC
Simple aes-256-cbc encryption tools
How to Install
npm install aes256cbc-enc
# or
yarn add aes256cbc-enc
How to Use
// in common JS
const { Aes256Cbc, generateKey } = require("aes256cbc-enc");
// in typescript
import { Aes256Cbc, generateKey } from "aes256cbc-enc";
// generate random key
const key = generateKey();
// create new instance
const aes = new Aes256Cbc({
key: "", // 64 character string hex
});
// or if you want generate from string
const aes = new Aes256Cbc({
rawKey: "", // any string
});
// print current key
const currKey = aes.getCurrentKey();
// encrypt and decrypt
const plainText = "test123";
const encryptedText = aes.encrypt(plainText);
const decryptedText = aes.decrypt(encryptedText);
console.log({ encryptedText, decryptedText });