Created
April 18, 2012 01:49
-
-
Save JasonGiedymin/2410489 to your computer and use it in GitHub Desktop.
Basic KeyGen CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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