crypto-conditions
Version:
Implementation of crypto-conditions in JavaScript
30 lines (21 loc) • 612 B
JavaScript
;
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
_Object$defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function xor(a, b) {
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
throw new Error('Arguments must be buffers');
}
if (a.length !== b.length) {
throw new Error('Buffers must be the same length');
}
var result = Buffer.alloc(a.length);
for (var i = 0; i < a.length; i++) {
result[i] = a[i] ^ b[i];
}
return result;
}
var _default = xor;
exports.default = _default;