Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/berendsliedrecht/bearnet-ts
Unofficial fernet version 03 implementation using XChaCha20Poly1305
https://github.com/berendsliedrecht/bearnet-ts
fernet xchacha20-poly1305
Last synced: 18 days ago
JSON representation
Unofficial fernet version 03 implementation using XChaCha20Poly1305
- Host: GitHub
- URL: https://github.com/berendsliedrecht/bearnet-ts
- Owner: berendsliedrecht
- License: apache-2.0
- Created: 2023-11-28T17:20:15.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-28T17:30:08.000Z (about 1 year ago)
- Last Synced: 2024-11-19T12:41:11.149Z (about 1 month ago)
- Topics: fernet, xchacha20-poly1305
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/bearnet
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE-2.0
Awesome Lists containing this project
README
# Bearnet
> Name is partially inspired by [hairnet](https://github.com/ferd/hairnet)
Implementation of [fernet](https://github.com/fernet/spec/blob/20dead475f53f11d20592baf29ad697163afc0cd/Spec.md), but using XChaCha20Poly1305 (following [unofficial version 3](https://github.com/mikelodder7/fernet/blob/deccfda5ff8d3c407175a2eace570bd4b7adc5ad/specs/version3.md)).
### Cryptography
This library fully relies on [@noble/ciphers](https://paulmillr.com/noble/) which is an unaudited library, use with caution.
## Usage
### Bearnet generated key
```typescript
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
```typescript
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
```typescript
import { Bearnet } from 'bearnet'const b = new Bearnet(new Uint8Array(32).fill(0))
const token = b.encode('hello')
```> Key and Token transfer happen OOB
```typescript
import { Bearnet } from 'bearnet'const b = new Bearnet(new Uint8Array(32).fill(0))
const msg = b.decode(token, { returnAsString: true })
assert(msg === 'hello')
```