https://github.com/bcomnes/xor-stream
Take two readable streams and return a readable stream with the xor of the two input chunks
https://github.com/bcomnes/xor-stream
Last synced: 8 months ago
JSON representation
Take two readable streams and return a readable stream with the xor of the two input chunks
- Host: GitHub
- URL: https://github.com/bcomnes/xor-stream
- Owner: bcomnes
- License: isc
- Created: 2016-02-29T04:15:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T17:02:17.000Z (about 6 years ago)
- Last Synced: 2025-05-23T10:42:48.262Z (about 1 year ago)
- Language: JavaScript
- Homepage: https://npmjs.com/package/xor-stream
- Size: 278 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xor-stream
Take two readable streams and return a readable stream that contains chunkA XOR chunkB
```
npm install xor-stream
```
[](https://travis-ci.org/bcomnes/xor-stream)
This can be used to calculate pairty blobs of the contents of two streams.
## Example
``` js
var xorStream = require('xor-stream')
var streamEqual = require('stream-equal')
var rs = require('fs').createReadStream
var pairity = xorStream(rs('pathA'), rs('pathB'))
var contentOfA = xorStream(pairity, rs('pathB'))
streamEqual(rs('pathA'), contentOfA, function (err, equal) {
console.log(equal) // true if file A is larger than File B
})
```
Right now, if one file is longer than the other, `xor-stream` pads the shorter stream with 0 bytes, so recovering shorter files from the longer file XOR pairty will have extra byte padding at the end.
## Background
- https://nodejs.org/api/buffer.html#buffer_new_buffer_str_encoding
- https://github.com/feross/safe-buffer
- https://www.npmjs.com/package/through2
- http://www.snapraid.it/compare
- https://en.wikipedia.org/wiki/Parchive
- ((chunkA) || 0byte) xor (chunkB || 0byte )
- https://github.com/mafintosh/stream-iterate
- https://github.com/mafintosh/sorted-union-stream