Git Product home page Git Product logo

node-asn1-tree's Introduction

Travis CI Coverage Status NPM Package

asn1-tree

Yet another ASN.1 encoder/decoder in JavaScript. Parses a binary ASN.1 buffer into a JavaScript object that describes the ASN.1 structure. Nested elements form a tree, and hence the name "asn1-tree", and a primitive value would just result in an object.

This is just an encoder/decoder. The interpretation of the structure (i.e. matching against a schema) is beyond the scope of this library. See asn1-mapper, an ASN.1 schema mapper, for that purpose.

Installation

npm install --save asn1-tree

Usage

const asn1Tree = require('asn1-tree');

const buffer = Buffer.from('3080800803221200644241f40201028301010000', 'hex');

const element = asn1Tree.decode(buffer);

The value of element will be:

{
  cls: 0,
  form: 1,
  tagCode: 16,
  elements: [{
    cls: 2,
    form: 0,
    tagCode: 0,
    value: Buffer.from([ 3, 34, 18, 0, 100, 66, 65, 244 ])
  }, {
    cls: 0,
    form: 0,
    tagCode: 2,
    value: Buffer.from([ 2 ])
  }, {
    cls: 2,
    form: 0,
    tagCode: 3,
    value: Buffer.from([ 1 ])
  }]
}

Going back:

const buffer = asn1Tree.encode(element);

node-asn1-tree's People

Contributors

atesgoral avatar dependabot[bot] avatar highmtworks avatar

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.