Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

sasaplus1/base62.js

Repository files navigation

base62.js

test npm version Try base62.js on RunKit renovate

base62 encode/decode library

Installation

npm

$ npm install base62.js

yarn

$ yarn add base62.js

Usage

node.js

const base62 = require('base62.js');

browser

<script src="base62.min.js"></script>

if use in Internet Explorer, base62.js needs Number.isSafeInteger polyfill:

<script src="https://polyfill.io/v3/polyfill.min.js?features=Number.isSafeInteger"></script>
<script src="base62.min.js"></script>

Example

base62.encode(39134); // "abc"
base62.decode('abc'); // 39134

const originalTable = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';

base62.encode(39134, originalTable); // "ABC"
base62.decode('ABC', originalTable); // 39134

Functions

see documents

License

The MIT license.