Skip to content

Convert Strings an Numbers to Base62 without worrying about overflowing Number.MAX_SAFE_INTEGER

License

Notifications You must be signed in to change notification settings

bnorton/base-62.js

Repository files navigation

base-62.js

Circle CI npm version

#Getting started

###Install it

$ npm install base-62.js

###Require it

var base62 = require('base-62.js');

###Use it to convert a number to a base 62 string

base62.encode('144928238032487217698238462873470924850921348902347582734698872031234');
//=> "17BHYOc7KWVceLGi6QvVTM1OELAxTLd1EwAtmQW"

###Use it to come back

base62.decode('17BHYOc7KWVceLGi6QvVTM1OELAxTLd1EwAtmQW');
//=> "144928238032487217698238462873470924850921348902347582734698872031234"

###Create a portable token from a MongoDB Object id (or any HEX string)

base62.encodeHex('556c9e573337620003000000');
//=> "ynKPk8OoB7EzcAus"

base62.decodeHex('ynKPk8OoB7EzcAus')
//=> "556c9e573337620003000000"

###Create a random token (API Access or a random password)

base62.random()
//=> "jplADVZ4H8gYGRXGSbki8zBZsv5"

About

Convert Strings an Numbers to Base62 without worrying about overflowing Number.MAX_SAFE_INTEGER

Resources

License

Stars

Watchers

Forks

Packages

No packages published