zuid
v0.1.0
Published
Compact representation of UUIDs
Downloads
10
Readme
ZUID - Compact UUID representation based on Crockford's Base 32
Sometimes it's necessary to represent UUID in a more compact way: to make URL shorter or to show it with smaller QR code.
This package formats it as 26 chars string.
There are number of benefits from such representation:
- Shorter! 26 chars vs 36 chars
- Easy to dictate - Case insensitive, similar looking chars: 0-O and 1-i-l are treated in same way
- URL-safe
- Works with node/browser and ts/js
- No dependencies
Installation
To use with your project
npm install zuid --save
or
yarn add zuid
Usage
import { encode, decode } from 'zuid';
console.log(encode('8affb7d3-f2e7-4053-8cf8-2da9f80964c3'));
// 8nzxqtfseeg2k8sy1dn7w0js63
console.log(decode('8nzxqtfseeg2k8sy1dn7w0js63'));
// 8affb7d3-f2e7-4053-8cf8-2da9f80964c3
Notes
It encodes UUIDs as Crockford's Base 32. Chars at positions 0 and 13 are hex values (similar to this package).