Skip to content

Instantly share code, notes, and snippets.

@vlucas
vlucas / encryption.js
Last active June 7, 2024 04:27
Stronger Encryption and Decryption in Node.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bits (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(ENCRYPTION_KEY), iv);
@msteckyefantis
msteckyefantis / unit.test.js
Last active February 26, 2018 22:53
General nodejs unit test template. Uses mocha, sinon, proxyquire, chai, and is-deep-frozen.
'use strict';
const ROOT_PATH = '../../';
const MODULE_PATH = 'lib/filename';
const FULL_MODULE_PATH = ROOT_PATH + MODULE_PATH;
const isDeepFrozen = require( 'is-deep-frozen' );
@requnix
requnix / bitcoin.conf
Created December 10, 2011 19:25
Default Bitcoin Configuration file
##############################################################
# Bitcoin configuration. Lines beginning with # are comments.#
##############################################################
# Network-related settings:
# Run on the test network instead of the real bitcoin network.
#testnet=1
# Connect via a socks4 proxy