Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

buffer-xor

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer-xor - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

2

index.js
module.exports = function xor (a, b) {
var length = Math.min(a.length, b.length)
var length = Math.max(a.length, b.length)
var buffer = new Buffer(length)

@@ -4,0 +4,0 @@

@@ -8,3 +8,3 @@ module.exports = function xorInplace (a, b) {

return a.slice(0, length)
return a
}
{
"name": "buffer-xor",
"version": "1.0.3",
"version": "2.0.0",
"description": "A simple module for bitwise-xor on buffers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,8 +19,12 @@ # buffer-xor

console.log(xor(a, b))
// => <Buffer f0 0f>
// => <Buffer f0 0f 0f>
```
Or for those seeking those few extra cycles, perform the operation in place:
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!_
``` javascript

@@ -32,4 +36,3 @@ var xorInplace = require("buffer-xor/inplace")

console.log(xorInplace(a, b))
// => <Buffer f0 0f>
// NOTE: xorInplace will return the shorter slice of its parameters
// => <Buffer f0 0f 0f>

@@ -43,2 +46,1 @@ // See that a has been mutated

## License [MIT](LICENSE)

@@ -11,3 +11,3 @@ [

"mutated": "f0f00f",
"expected": "f0f0"
"expected": "f0f00f"
},

@@ -17,3 +17,4 @@ {

"b": "f0ffff",
"expected": "f0f0"
"mutated": "f0f0",
"expected": "f0f0ff"
},

@@ -20,0 +21,0 @@ {

@@ -31,3 +31,3 @@ /* global describe, it */

assert.equal(actual.toString('hex'), f.expected)
assert.strictEqual(actual, a)

@@ -34,0 +34,0 @@ // a mutated, b unchanged

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc