lightsword
Version:
LightSword Secure SOCKS5 Proxy / iOS VPN Server
24 lines (23 loc) • 585 B
JavaScript
//-----------------------------------
// Copyright(c) 2015 Neko
//-----------------------------------
;
const stream = require('stream');
class XorStream extends stream.Transform {
constructor(x) {
super();
this.xor = x;
}
_transform(chunk, encoding, done) {
let me = this;
if (Buffer.isBuffer(chunk)) {
let data = chunk;
this.push(new Buffer(data.select(n => n ^ me.xor).toArray()));
}
else {
this.push(chunk);
}
done();
}
}
exports.XorStream = XorStream;