Code Monkey home page Code Monkey logo

b62's Introduction

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

b62's People

Contributors

dmarcelino avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.