@ibnlanre/cipher
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

@ibnlanre/cipher

TypeScript code style: prettier version

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);

Maintainers

Package Sidebar

Install

npm i @ibnlanre/cipher

Weekly Downloads

18

Version

2.3.0

License

MIT

Unpacked Size

8.58 MB

Total Files

11

Last publish

Collaborators

  • ibnlanre