# uuid-encoder

> Encode UUIDs into Base36 or any other system

Latest version **1.2.0** (published 2019-10-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install uuid-encoder
pnpm add uuid-encoder
yarn add uuid-encoder
bun add uuid-encoder
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-10-03 |
| First published | 2017-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/uuid-encoder) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Aleksi Asikainen |
| Maintainers | franksrevenge |
| Keywords | uuid, compress, compressor, compact, encode, encoder, encoding, base36, base32, base58, base62 |

## Links

- npm: https://www.npmjs.com/package/uuid-encoder
- Repository: https://github.com/salieri/uuid-encoder
- Homepage: https://github.com/salieri/uuid-encoder#readme
- Issues: https://github.com/salieri/uuid-encoder/issues
- npm.io page: https://npm.io/package/uuid-encoder

## Dependencies (1)

- [big-integer](https://npm.io/package/big-integer.md) ^1.6.46

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2019-10-03
- 1.1.0 — 2017-12-11
- 1.0.0 — 2017-12-11

## README

# UUID Encoder

Convert UUIDs into Base32, Base36, or any other encoding of your choice.

[![Build Status](https://travis-ci.org/salieri/uuid-encoder.svg?branch=master)](https://travis-ci.org/salieri/uuid-encoder) [![Coverage Status](https://coveralls.io/repos/github/salieri/uuid-encoder/badge.svg?branch=master)](https://coveralls.io/github/salieri/uuid-encoder?branch=master) [![Dependency Status](https://david-dm.org/salieri/uuid-encoder/status.svg)](https://david-dm.org/salieri/uuid-encoder#info=dependencies&view=table) [![Dev Dependency Status](https://david-dm.org/salieri/uuid-encoder/dev-status.svg)](https://david-dm.org/salieri/uuid-encoder#info=devDependencies&view=table)


## Usage

```js
const UuidEncoder = require('uuid-encoder');

// Create Base 36 encoder
const encoder = new UuidEncoder('base36');

// Encode an UUID
const encodedUuid = encoder.encode('38b9823d-fa1a-48e7-91fc-ee16ad091cf2');

// Decode an encoded UUID
const decodedUuid = encoder.decode(encodedUuid);
```


## API

### UuidEncoder([baseEncodingStr = 'base36'])

Instantiate a new encoder using the specified base encoder.

### string encode(string uuid)

Returns a string containing the encoded version of the `uuid`.

### string decode(string str)

Returns a string containing the decoded UUID from `str`.


## Encoding

### Built-In Encodings

| Type       | Charset  | Description |
| :--------- | :------- | :----------------------- |
| `'base2'`  | 0-1      | Binary encoding |
| `'base10'` | 0-9      | Decimal encoding |
| `'base16'` | 0-9, a-f | Hexadecimal encoding |
| `'base32'` | _Custom_ | Crockford's Base 32 |
| `'base36'` | 0-9, a-z | Base 36 (default) |
| `'base58'` | _Custom_ | Bitcoin Base 58 |
| `'base62'` | 0-9, A-Z, a-z | Base 62 |
| `'base64'` | 0-9, A-Z, a-z, +, / | Base 64 |
| `'base64url'` | 0-9, A-Z, a-z, -, _ | Base 64 URL encoding (RFC 4648) |



## Custom Encoding

To use a different set or count of encoding characters, simply pass a string
containing every desired letter to the constructor.

All custom encoding sets are **case sensitive**.

```js
const encoder = new UuidEncoder('02468ACEGI'); // weird base10
```

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