1.0.1 • Published 7 years ago

base-62 v1.0.1

Weekly downloads
24
License
MIT
Repository
-
Last release
7 years ago

Base62

travis javascript style guide npm downloads

Install

npm install base-62

How to use

base62 = require('base-62')
base62.encode(1234) // 'jU'
base62.decode('jU') // 1234

Custom Character Set Example

The default base 62 alphabet is 0-9a-zA-Z. This can be updated to a custom character set. Naturally, it must be 62 characters long.

Instead of the character set 0-9a-zA-Z you want to use 0-9A-Za-z, call the setAlphabet() method on the Base62 object passing in the string "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz". Note that all characters must be unique.

base62 = require('base-62')
base62.setAlphabet('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')
base62.encode(1234) // 'Ju'
base62.decode('Ju') // 1234

License

MIT. Copyright (c) Nicolas Lecoy.

1.0.1

7 years ago

1.0.0

7 years ago