@sqrls/tokens
v0.1.1
Published
A small helper library to handle token generation, inspired by slugid
Downloads
2
Readme
tokens
Absolutely tiny library to handle token generation, inspired by slugid.
How to use
This library provides two functions: genToken
, which creates new tokens, and tokenLength
, which calculates the expected token length. TypeSript:
import { genToken, tokenLength } from "@sqrls/tokens"; // or import default
console.log("Random base64url encoded token:", genToken());
console.log("A small token with 5 bytes (40 bits):", genToken(5));
console.log("A much larger token with 100 bytes (800 bits):", genToken(100));
console.log(`A 30-byte token should have a string length ${tokenLength(30)}`);