bearnet
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Bearnet

Name is partially inspired by hairnet

Implementation of fernet, but using XChaCha20Poly1305 (following unofficial version 3).

Cryptography

This library fully relies on @noble/ciphers which is an unaudited library, use with caution.

Usage

Bearnet generated key

import { Bearnet } from 'bearnet'

const b = new Bearnet()

const token = b.encode('hello')
const msg = b.decode(token, { returnAsString: true })

assert(msg === 'hello')

Or with your own key

import { Bearnet } from 'bearnet'

const b = new Bearnet(new Uint8Array(32).fill(0))

const token = b.encode('hello')
const msg = b.decode(token, { returnAsString: true })

assert(msg === 'hello')

Separated encoding and decoding

import { Bearnet } from 'bearnet'

const b = new Bearnet(new Uint8Array(32).fill(0))

const token = b.encode('hello')

Key and Token transfer happen OOB

import { Bearnet } from 'bearnet'

const b = new Bearnet(new Uint8Array(32).fill(0))

const msg = b.decode(token, { returnAsString: true })

assert(msg === 'hello')

/bearnet/

    Package Sidebar

    Install

    npm i bearnet

    Weekly Downloads

    0

    Version

    0.1.2

    License

    (MIT OR Apache-2.0)

    Unpacked Size

    21.5 kB

    Total Files

    7

    Last publish

    Collaborators

    • blu3beri