based.ts
A TypeScript library for working with arbitrary bases.
It can be installed globally if you want to generate base36-encoded UUIDs.
pnpm install --global @natoboram/based.ts
basedts
Base 36 UUID: 2pcugbwbg50o24pnu8h3u1f0b
Proper CLI options are planned for the future, but for now that's all I needed this package for.
pnpm i -D @natoboram/based.ts
import {
basedToBigInt,
bytesToBigInt,
getRandomBytes,
toBase,
} from "@natoboram/based.ts"
// Generate a base36-encoded UUID
const bytes = getRandomBytes()
const bigInt = bytesToBigInt(bytes)
const base36 = toBase(bigInt, 36n)
console.log("Base 36 UUID:", base36)
// Convert between two bases
const base64 = toBase(basedToBigInt("20zsnycqen1k898slr7xgnc9t", 36n), 64n)