Skip to content

Instantly share code, notes, and snippets.

@crapthings
Created November 22, 2013 09:58
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 crapthings/7597562 to your computer and use it in GitHub Desktop.
Save crapthings/7597562 to your computer and use it in GitHub Desktop.
var id = crypto.randomBytes(20).toString('hex');
//=> bb5dc8842ca31d4603d6aa11448d1654
var seed = crypto.randomBytes(20);
var id = crypto.createHash('sha1').update(seed).digest('hex');
//=> 06eb06693508052c950cf6d915e6f70a8419baac
//=> http://stackoverflow.com/questions/9407892/how-to-generate-random-sha1-hash-to-use-as-id-in-node-js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment