Skip to content

Instantly share code, notes, and snippets.

@DrPaulBrewer
Created October 4, 2017 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrPaulBrewer/a9135403122c0d0095cf0853e9b2d23e to your computer and use it in GitHub Desktop.
Save DrPaulBrewer/a9135403122c0d0095cf0853e9b2d23e to your computer and use it in GitHub Desktop.
create random AES-256 key in hex -- compatible with Google Cloud Storage
// Copyright 2017 Paul Brewer, Economic and Financial Technology Consulting LLC <drpaulbrewer@eaftc.com>
// License: The MIT License. See: https://opensource.org/licenses/MIT
// Google has an example using base64; hex is a little safer to copy/paste and recognize as incorect
// see https://cloud.google.com/storage/docs/using-encryption-keys
const crypto = require('crypto');
console.log("hex AES-256 random key follows");
const key = crypto.randomBytes(32);
console.log(key.toString('hex'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment