https://github.com/ribeaud/node-crypto-config
Small Node config extension which supports encryption
https://github.com/ribeaud/node-crypto-config
crypto node-config nodejs
Last synced: 8 months ago
JSON representation
Small Node config extension which supports encryption
- Host: GitHub
- URL: https://github.com/ribeaud/node-crypto-config
- Owner: ribeaud
- License: other
- Created: 2017-03-28T08:12:15.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-29T07:14:17.000Z (almost 9 years ago)
- Last Synced: 2025-07-05T22:31:35.640Z (9 months ago)
- Topics: crypto, node-config, nodejs
- Language: JavaScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://nodei.co/npm/crypto-config/)
[](https://travis-ci.org/ribeaud/node-crypto-config)
node-crypto-config
=============
Small **Node** [Config](https://github.com/lorenwest/node-config) extension which supports encryption.
Installation
------------
```bash
npm install crypto-config
```
Usage
-----
This library is a wrapper around [Config](https://github.com/lorenwest/node-config). On instantiation, each **string** property
value matching the pattern `ENC()` will go through the _handler_ specified in the constructor.
```javascript
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](http://www.jasypt.org/encrypting-configuration.html) for the inspiration.
License
-------
May be freely distributed under the [MIT license](https://raw.githubusercontent.com/ribeaud/node-crypto-config/master/LICENSE).
Copyright (c) 2017 Christian Ribeaud