Skip to content

Instantly share code, notes, and snippets.

@handcoding
handcoding / base62.js
Created May 13, 2024 16:07 — forked from droduit/base62.js
JS encode / decode base62
// Source : https://lowrey.me/encoding-decoding-base-62-in-es6-javascript/
const base62 = {
charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),
encode: integer => {
if (integer === 0) {
return 0;
}
let s = [];
while (integer > 0) {