Skip to content

Instantly share code, notes, and snippets.

@JasonGiedymin
Created April 18, 2012 01:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonGiedymin/2410489 to your computer and use it in GitHub Desktop.
Save JasonGiedymin/2410489 to your computer and use it in GitHub Desktop.
Basic KeyGen CoffeeScript
# Basic Keygen
# Briefly used at my startup
# Note: be mindful of any console logging or stdout logging when running this.
#
# By Jason Giedymin
# jasong _-@-_ apache -dot- org
#
crypto = require "crypto"
rbytes = require "rbytes"
base_spec =
method: "sha256" # md5 | sha1 | sha256 | sha512
encoding: "hex" #binary | hex | base64
bytes: 1024 * 2
generateKey = (spec = base_spec) ->
method = spec.method
encoding = spec.encoding
bytes = spec.bytes
return crypto.createHash(method).update(rbytes.randomBytes(bytes)).digest(encoding)
console.log generateKey()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment