0.0.1 • Published 1 year ago

encryptic v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Encryptic

A simple encryption library for Node.js

How it works

Assign random characters to each letter of the alphabet and use them to encrypt a message. The encryption key is stored in a JSON file and can be used to decrypt the message.

Installation

npm i encryptic

Example

const Encryptic = require('encryptic')

const encrypt = new Encryptic({ keys:{ "A":"B", "B":"C" /* etc */ }, fillMissing:true, randomLength: 3, keyFile:"keys.json", returnKey:false, randomEncoding:"hex" })
const encrypted_string = encrypt.encrypt("Hello World!")

console.log(encrypted_string) // Random string of characters
console.log(encrypt.decrypt(encrypted_string)) // "Hello World!"

Options

OptionTypeDefaultDescription
keysObject{}The encryption key.
fillMissingBooleanfalseFill missing characters with random characters.
randomLengthNumber1The length of the random characters.
keyFileStringnullThe file to store the encryption key in.
returnKeyBooleanfalseReturn the encryption on start.
randomEncodingString"hex"The encoding of the random characters, passed into crypto.randomBytes().

Methods

MethodParametersDescription
encryptstringEncrypt a string.
decryptstringDecrypt a string.

Special Values

Evaluate JavaScript String

{
"A":"$js:Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)"
}

Random

{
"A":"$random"
}