Skip to content

Instantly share code, notes, and snippets.

@coderaiser
Created December 9, 2014 08:43
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 coderaiser/af0c1822e0c3fa5ee0ba to your computer and use it in GitHub Desktop.
Save coderaiser/af0c1822e0c3fa5ee0ba to your computer and use it in GitHub Desktop.
(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