Skip to content
A simple module for bitwise-xor on buffers
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Merge pull request #8 from crypto-browserify/safebuf Aug 21, 2017
.gitignore adds first-pass implementation May 21, 2015
.travis.yml Update travis config Mar 12, 2016
LICENSE Initial commit May 19, 2015 README: single quotes only Feb 22, 2017
index.js use safe-buffer Aug 21, 2017
inplace.js Fix semantics, xor until largest buffer ends rather than smallest Mar 11, 2016
package.json 2.0.2 Aug 21, 2017


NPM Package Build Status


A simple module for bitwise-xor on buffers.


var xor = require('buffer-xor')
var a = new Buffer('00ff0f', 'hex')
var b = new Buffer('f0f0', 'hex')

console.log(xor(a, b))
// => <Buffer f0 0f 0f>

Or for those seeking those few extra cycles, perform the operation in place with xorInplace:

NOTE: xorInplace won't xor past the bounds of the buffer it mutates so make sure it is long enough!

var xorInplace = require('buffer-xor/inplace')
var a = new Buffer('00ff0f', 'hex')
var b = new Buffer('f0f0', 'hex')

console.log(xorInplace(a, b))
// => <Buffer f0 0f 0f>

// See that a has been mutated
// => <Buffer f0 0f 0f>

License MIT

You can’t perform that action at this time.