https://github.com/martinheidegger/uuid-b32
Convert uuid to and from base32 strings
https://github.com/martinheidegger/uuid-b32
base32 user-friendly uuid
Last synced: 6 months ago
JSON representation
Convert uuid to and from base32 strings
- Host: GitHub
- URL: https://github.com/martinheidegger/uuid-b32
- Owner: martinheidegger
- License: mit
- Created: 2021-12-15T03:49:18.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-15T04:02:38.000Z (almost 4 years ago)
- Last Synced: 2025-03-18T15:48:33.073Z (7 months ago)
- Topics: base32, user-friendly, uuid
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Convert uuid to and from base32
UUID's for legacy reasons are usually encoded as hex strings like: `5b9e4740-5d4c-11ec-a260-8f8d5ea1937c`.
This encoding is quite long and not very human friendly. Using this util you can convert them using
`base32` encoding, which looks like this `BEF4EG2X9G8YS8K0HY6NX8CKFG`.## JavaScript API
```javascript
const { encode, decode } = require('uuid-b32')// create a base32 encoded uuidv4
const uuidCrockfordEncoded = encode()
const uuidRFC4648Encoded = encode(null, 'RFC4648')// convert back to uuid
const uuid =
decode(uuidCrockfordEncoded) ||
decode(uuidRFC4648Encoded, 'RFC4648')// convert exisiting uuid to base32
encode(uuid)
```## Command Line Usage
You can also use it simply as a command line tool: `npx uuid-b32`
```
Generate or convert a uuid to/from base32 encodingUsage: uuid-b32 (--uuid [uuid]) (--variant [variant]) (--b32 [uuid]) (--uuid-v1) (--uuid-v4)
--variant ....... use base32 variant, supported variants: RFC3548, RFC4648, RFC4648-HEX, Crockford (default)
--uuid .......... convert input uuid instead of generating new one
--b32 ........... convert input base32 encoded uuid to uuid
--uuid-v1 ....... when creating a new uuid, use uuid-v1 variant
--uuid-v4 ....... when creating a new uuid, use uuid-v4 variant (default)
-v, --version ... print the version
-h, --help ...... print this helpCreate a base32 uuid:
uuid-b32
Input using stdin is supported
echo | uuid-b32 --uuid
echo | uuid-b32 --b32
```# License
[MIT](./LICENSE)