xor-stream-cipher

0.0.2 • Public • Published

xor-stream-cipher

build status AppVeyor Build Status


A simple xor stream cipher. Uses seed-bytes for the key stream.


Get it!

npm install --save xor-stream-cipher

Usage

var XOR = require('xor-stream-cipher')
var thru = require('stream').PassThrough()
 
var plain = 'the money is in the attic'
var shared = '419'
var a = XOR(shared)
var b = XOR(shared)
 
function ondata (name, chunk) {
  console.log(name + ':', chunk.toString())
}
 
a.pipe(thru).pipe(b)
 
a.on('data', ondata.bind(null, 'alice'))
b.on('data', ondata.bind(null, 'bob'))
 
a.end(plain)

API

XOR(init[, algo])

Create a new XOR stream. init is the seed for a random byte generator used as key stream. algo indicates the algorithm to use for the internal random number generator, defaults to 'alea'. Check out seedrandom for a list of supported algorithms.


License

MIT

Package Sidebar

Install

npm i xor-stream-cipher

Weekly Downloads

2

Version

0.0.2

License

MIT

Last publish

Collaborators

  • chiefbiiko