Skip to content

Instantly share code, notes, and snippets.

@frohoff
Last active August 29, 2015 14:01
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 frohoff/4bed435923c95a0019a8 to your computer and use it in GitHub Desktop.
Save frohoff/4bed435923c95a0019a8 to your computer and use it in GitHub Desktop.
long stream chain test
var crypto = require('crypto')
var hashType = process.argv[2] || 'sha1'
var numHashes = parseInt(process.argv[3] || 1)
// init chain with stdout
var piped = process.stdout
for (var i = 0; i < numHashes; i++) {
// prepend chain with new hash
var hash = crypto.createHash(hashType)
hash.pipe(piped)
piped = hash
}
//pipe stdin into chain
process.stdin.pipe(piped)
@frohoff
Copy link
Author

frohoff commented May 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment