Small Node Config extension which supports encryption.
npm install crypto-config
This library is a wrapper around Config. On instantiation, each string property
value matching the pattern ENC(<encrypted-value>)
will go through the handler specified in the constructor.
const assert = require('assert');
const crypto = require('crypto');
const algorithm = 'aes-256-ctr';
const Config = require('crypto-config');
// The key which has been used to encrypt the password
const salt = 'secret';
// This is the handler to decrypt your encrypted values
function decrypt(val) {
assert(text, "Unspecified text");
const decipher = crypto.createDecipher(algorithm, salt);
let dec = decipher.update(text, 'hex', 'utf8');
dec += decipher.final('utf8');
return dec;
}
// 'crypto-config' instantiation with handler.
const config = new Config(val => {
return decrypt(val);
}).config;
The Config contains two properties: orig (original configuration values) and config (the handled configuration values).
To Jasypt for the inspiration.
May be freely distributed under the MIT license. Copyright (c) 2017 Christian Ribeaud