Base62 encoding converts numbers (positive integers) to ASCII strings and vice versa:
import { encode, decode } from "base62";
encode(9999); // "7bH"
decode("7bH"); // 9999
decode(239000); // "10aQ"
decode("10aQ"); // 239000
You might also use a custom character set, i.e. something other than the default ASCII characters:
import { encode, decode, indexCharset } from "base62/custom";
// NB: must be a string of exactly 62 unique characters
let charset = indexCharset("äöü…$#@%!…ß");
encode(…, charset);
decode(…, charset);
- ensure Node is installed
npm install
downloads dependenciesnpm test
runs the test suite and checks code for stylistic consistency
This library is loosely based on Andrew Nesbitt's Base62.js.