mirror of
https://github.com/wu736139669/Monkey-Test.git
synced 2026-08-06 06:14:53 +00:00
32 lines
792 B
JavaScript
32 lines
792 B
JavaScript
var Transform = require('stream').Transform;
|
|
var inherits = require('inherits');
|
|
|
|
module.exports = CipherBase;
|
|
inherits(CipherBase, Transform);
|
|
function CipherBase() {
|
|
Transform.call(this);
|
|
}
|
|
CipherBase.prototype.update = function (data, inputEnd, outputEnc) {
|
|
this.write(data, inputEnd);
|
|
var outData = new Buffer('');
|
|
var chunk;
|
|
while ((chunk = this.read())) {
|
|
outData = Buffer.concat([outData, chunk]);
|
|
}
|
|
if (outputEnc) {
|
|
outData = outData.toString(outputEnc);
|
|
}
|
|
return outData;
|
|
};
|
|
CipherBase.prototype.final = function (outputEnc) {
|
|
this.end();
|
|
var outData = new Buffer('');
|
|
var chunk;
|
|
while ((chunk = this.read())) {
|
|
outData = Buffer.concat([outData, chunk]);
|
|
}
|
|
if (outputEnc) {
|
|
outData = outData.toString(outputEnc);
|
|
}
|
|
return outData;
|
|
}; |