Skip to content

ianbamforth/base62.js

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build status npm version Dependency Status devDependency Status Gitter chat

A javascript Base62 encode/decoder for node.js

Install

npm install base62

Usage

Default Character Set Example

Base62 = require('base62')
Base62.encode(999)  // 'g7'
Base62.decode('g7') // 999

Custom Character Set Example

The default character set 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 setCharacterSet() method on the Base62 object passing in the string "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz". Note that all characters must be unique.

Base62 = require('base62')
Base62.setCharacterSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
Base62.encode(999)  // 'G7'
Base62.decode('G7') // 999

Development

Source hosted at GitHub. Report Issues/Feature requests on GitHub Issues.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2015 Andrew Nesbitt. See LICENSE for details.

About

🔡 A javascript Base62 encode/decoder for node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%