Encode strings to binary arrays and back again
var binaryEncoderRing = require('binary-encoder-ring');
var fs = require('fs');
var ring = new binaryEncoderRing();
var sentenceLong = "The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a given text, such as the complete works of William Shakespeare."
var sentenceSmall = "bEeP bOoP";
var target = ring.encode(sentenceSmall);
console.log(ring.decode(target));
var targetLong = ring.encode(sentenceLong);
console.log(ring.decode(target));
fs.createReadStream('test.txt').pipe(ring.encodeStream()).pipe(ring.decodeStream()).pipe(process.stdout);
calling binaryEncoderRing.js with -p
preps the program to encode data for process.stdin
calling binaryEncoderRing.js with -pd
preps the program to decode data for process.stdin
echo 'anyong!' | node binaryEncoderRing.js -p
1011001 1010111 110101 110101 1100010 110010 110101 1101110 1001001 1010001 1101111 111101
echo 'anyong!' | node binaryEncoderRing.js -p | node binaryEncoderRing.js -pd
anyong!
useful if you're testing binary GA's
runs the example test.
var binaryEncoderRing = require('binary-encoder-ring');
Create a new instance of a ring.
returns an binary representation of the input string.
returns a string represenation of the binary array
create an encoding stream
return a decoding stream
With npm do:
npm install binary-encoder-ring
to get the library.
MIT