Code Monkey home page Code Monkey logo

base32lib's Introduction

Base 32 encoding/decoding for JavaScript

License npm version

Base 32 is between hexadecimal notation and Base 64 encoding. It's intended to be a human-friendly -- you don't have to worry about punctuation, capitalization, or letters/numbers that are easy to confuse, making it easier to transmit in handwriting or over the phone.

Base 32 will work the same with upper- or lowercase, you can mistake a number for a similar-looking letter, and it will still decode to the same data.

Getting started

In your shell, install with npm:

npm install base32lib

In your code:

const base32lib = require('base32lib')

// encodings available: crockford, rfc4648, z-32, geohash, 32hex
// The default one is RFC4648
const encoded = base32lib.encode('some data to encode 123', 'rfc4648') //onxw2zjamrqxiyjaorxsazlomnxwizjagezdg===
const encoded2 = base32lib.encode('Some data to encOde 123') //onxw2zjamrqxiyjaorxsazlomnxwizjagezdg===
console.log(encoded === encoded2) // true
const decoded = base32lib.decode(encoded) // some data to encode 123

The main specifications of something called "Base 32" are present in this library: RFC4648, Crockford, z-32, geohash, 32hex - see Wikipedia for some of them.

Minispec

  • When decoding, capital letters are converted to lowercase and the depending on the spec "ambiguous" letters mentioned might be converted to their numeric counterparts.
  • Each character corresponds to 5 bits of input.
  • Lexicographic order of strings is preserved through Base 32 encoding.

Formalia

Under MIT License.

base32lib's People

Contributors

dependabot[bot] avatar mdandre89 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.