libbasen v1.1.0
encoding/decoding from arbitrary base
Loading...
Searching...
No Matches
base58 Namespace Reference

Functions

bool isValid (const char *str, size_t str_size) noexcept
 
bool isValid (std::string_view str) noexcept
 
size_t sizeEncoded (std::span< const uint8_t > data)
 
size_t sizeDecoded (std::string_view str) noexcept
 
size_t encode (const uint8_t *data, size_t data_size, char *str, size_t str_size)
 
std::string encode (std::span< const uint8_t > data)
 
size_t decode (const char *str, size_t str_size, uint8_t *data, size_t data_size)
 
std::vector< uint8_t > decode (std::string_view str)
 
std::string encodeCheck (std::span< const uint8_t > data)
 
std::vector< uint8_t > decodeCheck (std::string_view str)
 

Variables

const char digits [59]
 bitcoin alphabet
 
const uint8_t map [256]
 

Function Documentation

◆ isValid() [1/2]

bool base58::isValid ( const char * str,
size_t str_size )
noexcept
Returns
checks what contains only alphabet chars
Warning
doesn't validate checksum, use decodeCheck instead

◆ isValid() [2/2]

bool base58::isValid ( std::string_view str)
noexcept
Parameters
strstring or string_view which you want to decode
Returns
checks what contains only alphabet chars
Warning
doesn't validate checksum, use decodeCheck instead

◆ sizeEncoded()

size_t base58::sizeEncoded ( std::span< const uint8_t > data)
Parameters
datavector or span of data which you want to encode
Returns
estimated size after encoding (for non-powers of two it is obviously larger)
Exceptions
basen::Exception(OVERFLOW)from baseN::sizeEncoded

◆ sizeDecoded()

size_t base58::sizeDecoded ( std::string_view str)
noexcept
Parameters
strstring or string_view which you want to decode
Returns
estimated size after decoding (for non-powers of two it is obviously larger)

◆ encode() [1/2]

size_t base58::encode ( const uint8_t * data,
size_t data_size,
char * str,
size_t str_size )
Parameters
data[in] pointer to data which you want encode
str[out] pointer to string for encoded data output
Returns
number of leading chars, which should be trimmed
Exceptions
basen::Exception(OVERFLOW)from base58::sizeEncoded
Warning
contain leading zeros, returns count of them

◆ encode() [2/2]

std::string base58::encode ( std::span< const uint8_t > data)
Parameters
datavector or span of data which you want to encode
Returns
encoded string
Exceptions
basen::Exception(OVERFLOW)from base58::sizeEncoded

◆ decode() [1/2]

size_t base58::decode ( const char * str,
size_t str_size,
uint8_t * data,
size_t data_size )
Parameters
str[in] pointer to string which you want decode
data[out] pointer to data for encoded string output
Returns
number of leading chars, which should be trimmed
Exceptions
basen::Exception(OUT_OF_ALPH)from baseN::decode
Warning
contain leading zeros, returns count of them

◆ decode() [2/2]

std::vector< uint8_t > base58::decode ( std::string_view str)
Parameters
strstring or string_view which you want to decode
Returns
decoded data
Exceptions
basen::Exception(OUT_OF_ALPH)from baseN::decode

◆ encodeCheck()

std::string base58::encodeCheck ( std::span< const uint8_t > data)
Parameters
datavector or span of data which you want to encode
Returns
encoded string + 4 first bytes of double sha256
Exceptions
basen::Exception(OVERFLOW)from base58::encode

◆ decodeCheck()

std::vector< uint8_t > base58::decodeCheck ( std::string_view str)
Parameters
strencoded string or string_view + 4 first bytes of double sha256
Returns
decoded data without 4 first bytes of double sha256
Exceptions
basen::Exception(OUT_OF_ALPH)from base58::decode
basen::Exception(PADDING)if str size < 4
basen::Exception(CHECKSUM)if checksum incorrect

Variable Documentation

◆ digits

const char base58::digits[59]
extern

bitcoin alphabet

◆ map

const uint8_t base58::map[256]
extern