nos-crypto
v1.0.2
Published
Crypto module for IBI Data's Node Starter
Downloads
11
Readme
NOS-Crypto
A crypto module for IBI Data's Node Starter
Crypto can be used to encrypt and decrypt inputs (strings, numbers, etc...).
Crypto Uses the node crypto API built into node. More information can be found on their Node API
Algorithms are based on OpenSSL, examples are 'aes192', etc. On recent OpenSSL releases, openssl list-cipher-algorithms will display the available cipher algorithms. OPEN SSL Algorithms
To Setup
- In the Config.js set your wanted algorithm and password for the hash
//CRYPTO SETTINGS
config.crypto = {};
config.crypto.algorithm = 'AES-256-CBC-HMAC-SHA256';
config.crypto.hashPass = 'PICK-A-PASSWORD';
To Call the Function
- Call the function with nos, if the function fails a decrypt, it will return false in a try catch block, so handle this accordingly.
// Encrypt Text
nos.crypto.encrypt(input);
// Decrypt Text
nos.crypto.decrypt(input);
There is also a handlebars helper to encrypt / decrypt with the same base settings.
{{!-- Encrypt / Decrypt Helpers --}}
{{encryptText data}}
{{decryptText data}}