# @ldapjs/asn1

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

Latest version **2.0.0** (published 2023-02-22) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @ldapjs/asn1
pnpm add @ldapjs/asn1
yarn add @ldapjs/asn1
bun add @ldapjs/asn1
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2023-02-22 |
| First published | 2022-03-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 78.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | melloc, jsumners, jgeurts, tonybrix |

## Links

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

## Recent versions

- 2.0.0 (latest) — 2023-02-22
- 2.0.0-rc.4 (rc) — 2023-02-21
- 1.0.0-rc.1 (next) — 2022-03-27
- 2.0.0-rc.3 — 2023-02-20
- 2.0.0-rc.2 — 2023-02-14
- 2.0.0-rc.1 — 2022-12-08
- 1.2.0 — 2022-06-26
- 1.2.0-rc.3 — 2022-06-26
- 1.2.0-rc.2 — 2022-06-19
- 1.2.0-rc.1 — 2022-06-17
- 1.0.1 — 2022-06-05
- 1.0.0 — 2022-03-27

## README

# `@ldapjs/asn1`

`@ldapjs/asn1` is a library for encoding and decoding ASN.1 datatypes in pure
JS. Currently BER encoding is supported.

### Decoding

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

```js
const { BerReader, BerTypes } = require('@ldapjs/asn1')
const reader = new BerReader(Buffer.from([0x30, 0x03, 0x01, 0x01, 0xff]))

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

### Encoding

The following generates the same payload as above.

```js
const { BerWriter } = require('@ldapjs/asn1');
const writer = new BerWriter();

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

console.log(writer.buffer);
```

## Installation

```sh
npm install @ldapjs/asn1
```

## Bugs

See <https://github.com/ldapjs/asn1/issues>.

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