@varkhedigital/crypthor

1.0.1 • Public • Published

@varkhedigital/crypthor

Crypthor is a simple encrypt and decrypt module for node.js

AND IT SHOULDN'T BE USED FOR ENCRYPTING PASSWORDS

This is a tool used for simple encryption of UTF-8 strings that need to be decrypted at a later time.

Crypthor(secret, {options})

  • secret: <string>
  • options: <Object>
    • algorithm: <string> Defaults to aes-128-cbc
    • iv: <string> Defaults to crypto.randomByte(x)
    • ivLength: <number> Defaults to Algorithm Standart (crypto.getCipherInfo(this.algorithm).ivLength)

Install

npm install @varkhedigital/crypthor

Usage

const Crypthor = require("@varkhedigital/crypthor");
const cipher = new Crypthor("VerySecureEncryptionKey");

const iv = cipher.iv.toString('hex');
console.log("Currently used IV: ", iv);
// ie: d7bc0270afa3371988464908eccd4b45

const encryptedString = cipher.encrypt("Encrypting Very Secret Text");
console.log("Encrypted String: ", encryptedString)
// ie: UvMqO4zi7mFiSHDMP82xcYTU68qa3cyPzwl6Spmx/IY=

const decryptedString = cipher.decrypt(encryptedString);
console.log("Decrypted String: ", decryptedString)
// ie: "Encrypting Very Secret Text"

Example Usage With Options

const Crypthor = require('@varkhedigital/crypthor');

const cipher = new Crypthor('VerySecureEncryptionKey', {
    iv:Buffer.from("d7bc0270afa3371988464908eccd4b45", 'hex'),
    ivLength:16
});

const encryptedString = cipher.encrypt('Encrypting Very Secret Text');

console.log("Encrypted String: ", encryptedString);
// ie: UvMqO4zi7mFiSHDMP82xcYTU68qa3cyPzwl6Spmx/IY=

const decryptedString = cipher.decrypt(encryptedString);
console.log("Decrypted String: ", decryptedString);
// ie: "Encrypting Very Secret Text"

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @varkhedigital/crypthor

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    5.88 kB

    Total Files

    5

    Last publish

    Collaborators

    • atillasimsek
    • lanson2332