You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1014 B

4 years ago
  1. # buffer-xor
  2. [![TRAVIS](https://secure.travis-ci.org/crypto-browserify/buffer-xor.png)](http://travis-ci.org/crypto-browserify/buffer-xor)
  3. [![NPM](http://img.shields.io/npm/v/buffer-xor.svg)](https://www.npmjs.org/package/buffer-xor)
  4. [![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
  5. A simple module for bitwise-xor on buffers.
  6. ## Examples
  7. ``` javascript
  8. var xor = require("buffer-xor")
  9. var a = new Buffer('00ff0f', 'hex')
  10. var b = new Buffer('f0f0', 'hex')
  11. console.log(xor(a, b))
  12. // => <Buffer f0 0f>
  13. ```
  14. Or for those seeking those few extra cycles, perform the operation in place:
  15. ``` javascript
  16. var xorInplace = require("buffer-xor/inplace")
  17. var a = new Buffer('00ff0f', 'hex')
  18. var b = new Buffer('f0f0', 'hex')
  19. console.log(xorInplace(a, b))
  20. // => <Buffer f0 0f>
  21. // NOTE: xorInplace will return the shorter slice of its parameters
  22. // See that a has been mutated
  23. console.log(a)
  24. // => <Buffer f0 0f 0f>
  25. ```
  26. ## License [MIT](LICENSE)