# asn1

> Contains parsers and serializers for ASN.1 (currently BER only)

Latest version **0.2.6** (published 2021-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install asn1
pnpm add asn1
yarn add asn1
bun add asn1
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.6 |
| Published | 2021-11-04 |
| First published | 2011-11-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/asn1) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 19.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 63 |
| Author | Joyent |
| Maintainers | todd.whiteman, kusor, wyatt, michael.hicks, bahamat, chudley, tchameroy, dbuell, pfmooney, mcavage, arekinath, melloc |

## Links

- npm: https://www.npmjs.com/package/asn1
- Repository: https://github.com/joyent/node-asn1
- Homepage: https://github.com/joyent/node-asn1#readme
- Issues: https://github.com/joyent/node-asn1/issues
- npm.io page: https://npm.io/package/asn1

## Dependencies (1)

- [safer-buffer](https://npm.io/package/safer-buffer.md) ~2.1.0

## Recent versions

- 0.2.6 (latest) — 2021-11-04
- 0.2.4 — 2018-08-02
- 0.2.3 — 2015-09-30
- 0.2.2 — 2014-09-03
- 0.2.1 — 2014-04-04
- 0.2.0 — 2014-02-24
- 0.1.11 — 2012-01-06
- 0.1.5 — 2011-12-08
- 0.1.6 — 2011-12-08
- 0.1.7 — 2011-12-08
- 0.1.10 — 2011-12-08
- 0.1.3 — 2011-12-08
- 0.1.4 — 2011-12-08
- 0.1.0 — 2011-12-08
- 0.1.1 — 2011-12-08
- … 3 more at https://npm.io/package/asn1/versions

## README

node-asn1 is a library for encoding and decoding ASN.1 datatypes in pure JS.
Currently BER encoding is supported; at some point I'll likely have to do DER.

## Usage

Mostly, if you're *actually* needing to read and write ASN.1, you probably don't
need this readme to explain what and why.  If you have no idea what ASN.1 is,
see this: ftp://ftp.rsa.com/pub/pkcs/ascii/layman.asc

The source is pretty much self-explanatory, and has read/write methods for the
common types out there.

### Decoding

The following reads an ASN.1 sequence with a boolean.

    var Ber = require('asn1').Ber;

    var reader = new Ber.Reader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]));

    reader.readSequence();
    console.log('Sequence len: ' + reader.length);
    if (reader.peek() === Ber.Boolean)
      console.log(reader.readBoolean());

### Encoding

The following generates the same payload as above.

    var Ber = require('asn1').Ber;

    var writer = new Ber.Writer();

    writer.startSequence();
    writer.writeBoolean(true);
    writer.endSequence();

    console.log(writer.buffer);

## Installation

    npm install asn1

## License

MIT.

## Bugs

See <https://github.com/joyent/node-asn1/issues>.

---
_Source: https://npm.io/package/asn1 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
