Socket
Socket
Sign inDemoInstall

b62

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    b62

Encode and decode strings to base62


Version published
Maintainers
1
Created

Readme

Source

npm version Build Status

b62

Encode and decode strings to base62 (and others)

Overview

The most popular base62 encoder and others only support converting a number to base62. This becomes a problem when trying to convert a big number with a precision higher than 52 bits like, for example, an UUID. Hence b62, which allows to convert strings (and not only) to base62.

Meanwhile I've found base-x which is much faster (20x) than b62! The only nuisance is that you need to supply a buffer. If performance is important to you, use base-x! In the future b62 may be changed to use base-x underneath.

Instalation

npm i b62 -S

Usage

var b62 = require('b62');

var encoded = b62.encode("Hello World!");
// -> t8DGCJrgKz3AYSDn

var decoded = b62.decoded("t8DGCJrgKz3AYSDn");
// -> Hello World!

You can also use other bases, for example:

var b64 = b62("-_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");

var encoded = b64.encode("Hi this is b64 example");
// -> _6og_Oo4zN64zN646Qb0_zs43Hq4Lz

var decoded = b62.decoded("t8DGCJrgKz3AYSDn");
// -> Hi this is b64 example

License

MIT

Keywords

FAQs

Last updated on 27 May 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc