Code Monkey home page Code Monkey logo

base-x's Introduction

base-x License GitHub Stars GitHub Forks GitHub Watchers Tweet

Build Status

BaseX encoder / decoder for C++

This is a fast base encoder / decoder of any given alphabet.

Example

// example.cc
// g++ -std=c++14 -o example example.cc

#include <iostream>
#include "base_x.hh"

int main() {
    auto encoded = Base58::base58().encode("Hello world!");

    std::cout << encoded << std::endl;
    // => 1LDlk6QWOejX6rPrJ

    return 0;
}

Compilation

  • g++ and clang++ are supported.
  • C++14 is required.

Alphabets

See below for a list of commonly recognized alphabets, and their respective base.

Base Factory Alphabet
2 base2::base2() 01
2 base8::base8() 01234567
11 bas11::bas11() 0123456789a
16 base16::base16() 0123456789abcdef
32 base32::base32() 0123456789ABCDEFGHJKMNPQRSTVWXYZ
36 base36::base36() 0123456789abcdefghijklmnopqrstuvwxyz
58 base58::base58() 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
58 base58::bitcoin() 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
58 base58::gmp() 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv
58 base58::ripple() rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz
58 base58::flickr() 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
62 base62::base62() 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
62 base62::inverted() 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
64 base64::base64() ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
64 base64::urlsafe() ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_
66 base66::base66() ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.!~

How it works

It encodes octet arrays by doing long divisions on all significant digits in the array, creating a representation of that number in the new base.

If you need standard hex encoding, or base64 encoding, this module is NOT appropriate.

Author

German Mendez Bravo (Kronuz)

Follow on GitHub Follow on Twitter

License

MIT License. See LICENSE for details.

Copyright (c) 2017 German Mendez Bravo (Kronuz) @ german dot mb at gmail.com

base-x's People

Contributors

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