Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hazae41/asn1

Zero-copy ASN.1 and DER coding 🏎️
https://github.com/hazae41/asn1

asn1 browser decoding der encoding esmodules javascript nodejs parser typescript unit-testing zero-copy

Last synced: 3 months ago
JSON representation

Zero-copy ASN.1 and DER coding 🏎️

Awesome Lists containing this project

README

        



```bash
npm i @hazae41/asn1
```

[**Node Package 📦**](https://www.npmjs.com/package/@hazae41/asn1)

## Features

### Current features
- 100% TypeScript and ESM
- No external dependency
- Rust-like patterns
- Zero-copy DER <=> ASN1 reading and writing
- Almost all universal triplets
- Implicit and explicit tagged types

### [Upcoming features](https://github.com/sponsors/hazae41)
- More string types
- More encodings

## Usage

```typescript
import { DER } from "@hazae41/asn1"

const input = new Uint8Array([0x01, 0x01, 0xFF])

const triplet = DER.tryFromBytes(input).unwrap() // Boolean

console.log(triplet.toString()) // "BOOLEAN true"

const output = DER.tryToBytes(triplet).unwrap() // Uint8Array([0x01, 0x01, 0xFF])
```