Skip to content

Kronuz/base-x

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published