cloudcmd/lib/server/hash.js
2013-11-19 09:33:51 +00:00

36 lines
791 B
JavaScript

(function (object) {
'use strict';
var util = require('util'),
crypto = require('crypto'),
Writable = require('stream').Writable;
object.create = 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;
};
}
})(this);