0.0.1 • Published 1 year ago
encryptic v0.0.1
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
Option | Type | Default | Description |
---|---|---|---|
keys | Object | {} | The encryption key. |
fillMissing | Boolean | false | Fill missing characters with random characters. |
randomLength | Number | 1 | The length of the random characters. |
keyFile | String | null | The file to store the encryption key in. |
returnKey | Boolean | false | Return the encryption on start. |
randomEncoding | String | "hex" | The encoding of the random characters, passed into crypto.randomBytes(). |
Methods
Method | Parameters | Description |
---|---|---|
encrypt | string | Encrypt a string. |
decrypt | string | Decrypt 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"
}
0.0.1
1 year ago