This is a fast base encoder / decoder of any given alphabet.
// 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;
}
- g++ and clang++ are supported.
- C++14 is required.
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-_.!~ |
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.
MIT License. See LICENSE for details.
Copyright (c) 2017 German Mendez Bravo (Kronuz) @ german dot mb at gmail.com