Skip to content

ribeaud/node-crypto-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Build Status

node-crypto-config

Small Node Config extension which supports encryption.

Installation

  npm install crypto-config

Usage

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).

Thanks

To Jasypt for the inspiration.

License

May be freely distributed under the MIT license. Copyright (c) 2017 Christian Ribeaud

About

Small Node config extension which supports encryption

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published