Created
December 9, 2014 08:43
-
-
Save coderaiser/af0c1822e0c3fa5ee0ba to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(function () { | |
'use strict'; | |
var util = require('util'), | |
crypto = require('crypto'), | |
Writable = require('stream').Writable; | |
module.exports = function() { | |
var ret; | |
if (Writable) { | |
util.inherits(WS, Writable); | |
ret = new WS(); | |
} | |
return ret; | |
}; | |
function WS(opt) { | |
var sha = crypto.createHash('sha1'); | |
Writable.call(this, opt); | |
this._write = function(chunk, enc, next) { | |
sha.update(chunk); | |
next(); | |
}; | |
this.get = function() { | |
var hex = sha.digest('hex'); | |
return hex; | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment