Coder Social home page Coder Social logo

packbits's Introduction

packbits

An implementation of the PackBits algorithm.

Installation

npm install packbits

Usage

var packbits = require('packbits');

Encode or decode a string of hex bytes with or without separating spaces.

encode

packbits.encode('AA AA AA 80 00 2A AA AA AA AA 80 00 2A 22 AA AA AA AA AA AA AA AA AA AA');
//-> FEAA0280002AFDAA0380002A22F7AA

decode

packbits.decode('FE AA 02 80 00 2A FD AA 03 80 00 2A 22 F7 AA');
//-> AAAAAA80002AAAAAAAAA80002A22AAAAAAAAAAAAAAAAAAAA

Examples

See examples/ directory

packbits's People

Contributors

dave-irvine avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

packbits's Issues

bytesToHex is missing?

Hi,
I'm using the packbits module currently and found that bytesToHex didn't define in encode.js, is there really missing or just misunderstanding?

this implementation is not lossles

example

var packbits = require('../');

function code(p){
var out = packbits.encode(p);
var out2 = packbits.decode(out);
console.log(${p} enc=> ${out} dec=> ${out2});

}

for( var i=0;i<=255;i++){
var ar = new Uint8Array(1);
ar[0] = i;
code(Buffer.from(ar).toString('hex'));
}

output :

.
.
.
36 enc=> 0054 dec=> 54
37 enc=> 0055 dec=> 55
.
.
.
fe enc=> 0054 dec=> 54
ff enc=> 0055 dec=> 55

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.