syndilights/displayclienthtml/websocket_demo/node_modules/websocket/lib/xor.fallback.js

13 lines
361 B
JavaScript
Raw Normal View History

2013-09-01 22:54:51 +02:00
module.exports = {
xor: function (payload, maskBytes, maskPos) {
var end = payload.length;
if (typeof(maskPos) !== 'number') {
maskPos = 0;
}
for (var i=0; i < end; i++) {
payload[i] = payload[i] ^ maskBytes[maskPos];
maskPos = (maskPos + 1) & 3;
}
return maskPos;
}
};