Simple Crypto Wrapper For Config
npm install github:perusworld/node-config-crypto-wrapper --save
Assuming the following is config with and encrypted property
{
"cryptoConfig": {
"entry": "encrypted:1830da46bc726b7866fce42c2ab91bc33f4267a52a42a170830eedd6b9f43351"
}
}
let cryptoWrapperApi = require('node-config-crypto-wrapper').wrapper();
let cryptoWrapper = new cryptoWrapperApi.DefaultConfigCryptoWrapper({}, {});
cryptoWrapper.loadConfig('cryptoConfig', (err, cryptoConfig) => {
//cryptoConfig now has the field decrypted
});
With the options
let cryptoWrapperApi = require('node-config-crypto-wrapper').wrapper();
let cryptoWrapper = new cryptoWrapperApi.DefaultConfigCryptoWrapper({
algorithm: 'aes256',
password: 'changeit',
format: 'hex',
decryptedFormat: 'utf8'
}, {});
cryptoWrapper.loadConfig('cryptoConfig', (err, cryptoConfig) => {
//cryptoConfig now has the field decrypted
});
Assuming the following is config with and encrypted property
{
"customCryptoConfig": {
"entry": "encrypted:This is a sample text"
}
}
let cryptoWrapperApi = require('node-config-crypto-wrapper').wrapper();
let customCryptoWrapper = new cryptoWrapperApi.ConfigCryptoWrapper({
//your crypto handler impl
cryptoHandler : {
//passthrough
encrypt: (str, callback) => {
callback(null, str);
},
//passthrough
decrypt: (cip, callback) => {
callback(null, cip);
}
}
});
customCryptoWrapper.loadConfig('customCryptoConfig', (err, cryptoConfig) => {
//cryptoConfig now has the field decrypted
});