pax_global_header00006660000000000000000000000064126011721740014513gustar00rootroot0000000000000052 comment=8f92b79a8b8133c26a7ae1af09b2c84ec6e3f426 buffer-xor-1.0.3/000077500000000000000000000000001260117217400135735ustar00rootroot00000000000000buffer-xor-1.0.3/.gitignore000066400000000000000000000000151260117217400155570ustar00rootroot00000000000000node_modules buffer-xor-1.0.3/.travis.yml000066400000000000000000000002451260117217400157050ustar00rootroot00000000000000language: node_js before_install: - "npm install npm -g" node_js: - "0.12" env: - TEST_SUITE=standard - TEST_SUITE=unit script: "npm run-script $TEST_SUITE" buffer-xor-1.0.3/LICENSE000066400000000000000000000020711260117217400146000ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Daniel Cousens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. buffer-xor-1.0.3/README.md000066400000000000000000000017661260117217400150640ustar00rootroot00000000000000# buffer-xor [![TRAVIS](https://secure.travis-ci.org/crypto-browserify/buffer-xor.png)](http://travis-ci.org/crypto-browserify/buffer-xor) [![NPM](http://img.shields.io/npm/v/buffer-xor.svg)](https://www.npmjs.org/package/buffer-xor) [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) A simple module for bitwise-xor on buffers. ## Examples ``` javascript var xor = require("buffer-xor") var a = new Buffer('00ff0f', 'hex') var b = new Buffer('f0f0', 'hex') console.log(xor(a, b)) // => ``` Or for those seeking those few extra cycles, perform the operation in place: ``` javascript var xorInplace = require("buffer-xor/inplace") var a = new Buffer('00ff0f', 'hex') var b = new Buffer('f0f0', 'hex') console.log(xorInplace(a, b)) // => // NOTE: xorInplace will return the shorter slice of its parameters // See that a has been mutated console.log(a) // => ``` ## License [MIT](LICENSE) buffer-xor-1.0.3/index.js000066400000000000000000000003161260117217400152400ustar00rootroot00000000000000module.exports = function xor (a, b) { var length = Math.min(a.length, b.length) var buffer = new Buffer(length) for (var i = 0; i < length; ++i) { buffer[i] = a[i] ^ b[i] } return buffer } buffer-xor-1.0.3/inline.js000066400000000000000000000000461260117217400154070ustar00rootroot00000000000000module.exports = require('./inplace') buffer-xor-1.0.3/inplace.js000066400000000000000000000002721260117217400155450ustar00rootroot00000000000000module.exports = function xorInplace (a, b) { var length = Math.min(a.length, b.length) for (var i = 0; i < length; ++i) { a[i] = a[i] ^ b[i] } return a.slice(0, length) } buffer-xor-1.0.3/package.json000066400000000000000000000014051260117217400160610ustar00rootroot00000000000000{ "name": "buffer-xor", "version": "1.0.3", "description": "A simple module for bitwise-xor on buffers", "main": "index.js", "scripts": { "standard": "standard", "test": "npm run-script unit", "unit": "mocha" }, "repository": { "type": "git", "url": "https://github.com/crypto-browserify/buffer-xor.git" }, "bugs": { "url": "https://github.com/crypto-browserify/buffer-xor/issues" }, "homepage": "https://github.com/crypto-browserify/buffer-xor", "keywords": [ "bits", "bitwise", "buffer", "buffer-xor", "crypto", "inline", "math", "memory", "performance", "xor" ], "author": "Daniel Cousens", "license": "MIT", "devDependencies": { "mocha": "*", "standard": "*" } } buffer-xor-1.0.3/test/000077500000000000000000000000001260117217400145525ustar00rootroot00000000000000buffer-xor-1.0.3/test/fixtures.json000066400000000000000000000004561260117217400173230ustar00rootroot00000000000000[ { "a": "000f", "b": "f0ff", "expected": "f0f0" }, { "a": "000f0f", "b": "f0ff", "mutated": "f0f00f", "expected": "f0f0" }, { "a": "000f", "b": "f0ffff", "expected": "f0f0" }, { "a": "000000", "b": "000000", "expected": "000000" } ] buffer-xor-1.0.3/test/index.js000066400000000000000000000020311260117217400162130ustar00rootroot00000000000000/* global describe, it */ var assert = require('assert') var xor = require('../') var xorInplace = require('../inplace') var fixtures = require('./fixtures') describe('xor', function () { fixtures.forEach(function (f) { it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () { var a = new Buffer(f.a, 'hex') var b = new Buffer(f.b, 'hex') var actual = xor(a, b) assert.equal(actual.toString('hex'), f.expected) // a/b unchanged assert.equal(a.toString('hex'), f.a) assert.equal(b.toString('hex'), f.b) }) }) }) describe('xor/inplace', function () { fixtures.forEach(function (f) { it('returns ' + f.expected + ' for ' + f.a + '/' + f.b, function () { var a = new Buffer(f.a, 'hex') var b = new Buffer(f.b, 'hex') var actual = xorInplace(a, b) assert.equal(actual.toString('hex'), f.expected) // a mutated, b unchanged assert.equal(a.toString('hex'), f.mutated || f.expected) assert.equal(b.toString('hex'), f.b) }) }) })