diff options
Diffstat (limited to 'node_modules/buffer-xor')
| -rw-r--r-- | node_modules/buffer-xor/.npmignore | 1 | ||||
| -rw-r--r-- | node_modules/buffer-xor/.travis.yml | 9 | ||||
| -rw-r--r-- | node_modules/buffer-xor/LICENSE | 21 | ||||
| -rw-r--r-- | node_modules/buffer-xor/README.md | 41 | ||||
| -rw-r--r-- | node_modules/buffer-xor/index.js | 10 | ||||
| -rw-r--r-- | node_modules/buffer-xor/inline.js | 1 | ||||
| -rw-r--r-- | node_modules/buffer-xor/inplace.js | 9 | ||||
| -rw-r--r-- | node_modules/buffer-xor/package.json | 37 | ||||
| -rw-r--r-- | node_modules/buffer-xor/test/fixtures.json | 23 | ||||
| -rw-r--r-- | node_modules/buffer-xor/test/index.js | 38 | 
10 files changed, 190 insertions, 0 deletions
| diff --git a/node_modules/buffer-xor/.npmignore b/node_modules/buffer-xor/.npmignore new file mode 100644 index 000000000..3c3629e64 --- /dev/null +++ b/node_modules/buffer-xor/.npmignore @@ -0,0 +1 @@ +node_modules diff --git a/node_modules/buffer-xor/.travis.yml b/node_modules/buffer-xor/.travis.yml new file mode 100644 index 000000000..d9f695b75 --- /dev/null +++ b/node_modules/buffer-xor/.travis.yml @@ -0,0 +1,9 @@ +language: 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" diff --git a/node_modules/buffer-xor/LICENSE b/node_modules/buffer-xor/LICENSE new file mode 100644 index 000000000..bba52181d --- /dev/null +++ b/node_modules/buffer-xor/LICENSE @@ -0,0 +1,21 @@ +The 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. diff --git a/node_modules/buffer-xor/README.md b/node_modules/buffer-xor/README.md new file mode 100644 index 000000000..007f05828 --- /dev/null +++ b/node_modules/buffer-xor/README.md @@ -0,0 +1,41 @@ +# buffer-xor + +[](http://travis-ci.org/crypto-browserify/buffer-xor) +[](https://www.npmjs.org/package/buffer-xor) + +[](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)) +// => <Buffer f0 0f> +``` + + +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)) +// => <Buffer f0 0f> +// NOTE: xorInplace will return the shorter slice of its parameters + +// See that a has been mutated +console.log(a) +// => <Buffer f0 0f 0f> +``` + + +## License [MIT](LICENSE) + diff --git a/node_modules/buffer-xor/index.js b/node_modules/buffer-xor/index.js new file mode 100644 index 000000000..85ee6f631 --- /dev/null +++ b/node_modules/buffer-xor/index.js @@ -0,0 +1,10 @@ +module.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 +} diff --git a/node_modules/buffer-xor/inline.js b/node_modules/buffer-xor/inline.js new file mode 100644 index 000000000..87975703d --- /dev/null +++ b/node_modules/buffer-xor/inline.js @@ -0,0 +1 @@ +module.exports = require('./inplace') diff --git a/node_modules/buffer-xor/inplace.js b/node_modules/buffer-xor/inplace.js new file mode 100644 index 000000000..d71c172ce --- /dev/null +++ b/node_modules/buffer-xor/inplace.js @@ -0,0 +1,9 @@ +module.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) +} diff --git a/node_modules/buffer-xor/package.json b/node_modules/buffer-xor/package.json new file mode 100644 index 000000000..5074b0221 --- /dev/null +++ b/node_modules/buffer-xor/package.json @@ -0,0 +1,37 @@ +{ +  "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": "*" +  } +} diff --git a/node_modules/buffer-xor/test/fixtures.json b/node_modules/buffer-xor/test/fixtures.json new file mode 100644 index 000000000..6f3431efc --- /dev/null +++ b/node_modules/buffer-xor/test/fixtures.json @@ -0,0 +1,23 @@ +[ +  { +    "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" +  } +] diff --git a/node_modules/buffer-xor/test/index.js b/node_modules/buffer-xor/test/index.js new file mode 100644 index 000000000..06eacab4f --- /dev/null +++ b/node_modules/buffer-xor/test/index.js @@ -0,0 +1,38 @@ +/* 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) +    }) +  }) +}) | 
