# @omegajs/id-encoding

> Transforms Scroll keys between z-base32 and hexadecimal formats, enabling seamless conversion and compatibility.

Latest version **1.0.0** (published 2024-01-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @omegajs/id-encoding
pnpm add @omegajs/id-encoding
yarn add @omegajs/id-encoding
bun add @omegajs/id-encoding
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-01-25 |
| First published | 2024-01-25 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | l1feglobal |

## Links

- npm: https://www.npmjs.com/package/@omegajs/id-encoding
- Repository: https://lab.l1fe.tech/omega/id-encoding
- Homepage: https://lab.l1fe.tech/omega/id-encoding#readme
- Issues: https://lab.l1fe.tech/omega/id-encoding/issues
- npm.io page: https://npm.io/package/@omegajs/id-encoding

## Dependencies (2)

- [b4a](https://npm.io/package/b4a.md) ^1.5.3
- [z32](https://npm.io/package/z32.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2024-01-25

## README

# Scroll ID Encoding
## @omegajs/id-encoding
Transforms Scroll keys between z-base32 and hexadecimal formats, enabling seamless conversion and compatibility.


## Install Via L1FE's NPM
```
npm config set registry https://npm.l1fe.tech
npm install @omegajs/id-encoding
```

## Install Via L1FE's Git Repository
```
git clone https://lab.l1fe.tech/omega/id-encoding.git
cd id-encoding
npm install
```

## Usage

```js
const { encode, decode, normalize } = require('@omegajs/id-encoding')

const id = encode(scroll.key) // (z-base32 String)
const hexEncoded = scroll.key.toString('hex')

const scroll = new Scroll(ram, decode(id)) 
const scroll2 = new Scroll(ram, decode(hexEncoded)) // Will also work with hex

const id2 = normalize(id)
const id3 = normalize(hexEncoded)
```

## API

#### `const id = encode(scrollKey)`

Encodes a 32-byte Scroll key into a z-base32 id.

`scrollKey` must be a Buffer or an ArrayBuffer.

#### `const buf = decode(scrollId)`

Decodes an id into a Scroll key.

If `scrollId` is a 52-character String, it will be decoded as z-base32.

If `scrollId` is a 64-character String, it will be decoded as hex.

If `scrollId` is already a Buffer and is a valid id, it will be returned as-is.

#### `const id = normalize(any)`

Decodes and encodes the input `any` to always return a z-base32 id.

#### `isValid(any)`

Returns a boolean indicating whether the key is a valid Scroll key (meaning that it can be decoded/normalised).

## License

Apache-2.0

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