Skip to content

Encode UUIDs to readable keys with Crockford base32

License

Notifications You must be signed in to change notification settings

nashaddams/uuidkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uuidkey

JSR JSR score main

Encode UUIDs to readable keys with Crockford base32, inspired by agentstation/uuidkey's approach for making beautiful API keys.

Usage

import { decode, encode, generate, validate } from "@nashaddams/uuidkey";

encode("01945655-0794-7259-800b-614c6ea29659"); // -> 06A5CN8-0YA74P8-G05P2K0-DTH9CP8
decode("06A5CN8-0YA74P8-G05P2K0-DTH9CP8"); // -> 01945655-0794-7259-800b-614c6ea29659
validate("06A5CN8-0YA74P8-G05P2K0-DTH9CP8"); // -> true
generate(); // -> { key: "06A5CQ8-SGRQZ7G-KHQWGF0-PM9JZ90", uuid: "0194565d-cc31-7f9e-9c6f-c83cb5132fa4" }

See the docs for further details.

Alternatively, uuidkey can also be run via CLI:

deno run -R=. jsr:@nashaddams/uuidkey [--help]