libbasen v1.1.0
encoding/decoding from arbitrary base
Loading...
Searching...
No Matches
base64 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
 
void encode (const uint8_t *data, size_t data_size, char *str, size_t str_size)
 
std::string encode (std::span< const uint8_t > data)
 
void decode (const char *str, size_t str_size, uint8_t *data, size_t data_size)
 
std::vector< uint8_t > decode (std::string_view str)
 

Variables

const char digits [65]
 
const uint8_t map [256]
 

Function Documentation

◆ isValid() [1/2]

bool base64::isValid ( const char * str,
size_t str_size )
noexcept
Returns
checks what contains only alphabet chars and ends with no more than two '=' chars

◆ isValid() [2/2]

bool base64::isValid ( std::string_view str)
noexcept
Parameters
strstring or string_view which you want to decode
Returns
checks what contains only alphabet chars and ends with no more than two '=' chars

◆ sizeEncoded()

size_t base64::sizeEncoded ( std::span< const uint8_t > data)
Parameters
datavector or span of data which you want to encode
Returns
exact size after encoding
Exceptions
basen::Exception(OVERFLOW)if there is an overflow

◆ sizeDecoded()

size_t base64::sizeDecoded ( std::string_view str)
noexcept
Parameters
strstring or string_view which you want to decode
Returns
exact size after decoding

◆ encode() [1/2]

void base64::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
Exceptions
basen::Exception(OVERFLOW)from base64::sizeEncoded
basen::Exception(LENGTH)if not enough allocated length

◆ encode() [2/2]

std::string base64::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 base64::sizeEncoded
basen::Exception(LENGTH)if not enough allocated length

◆ decode() [1/2]

void base64::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
Exceptions
basen::Exception(LENGTH)if not enough allocated length
basen::Exception(OUT_OF_ALPH)if out of digits map
basen::Exception(PADDING)if incorrect padding

◆ decode() [2/2]

std::vector< uint8_t > base64::decode ( std::string_view str)
Parameters
strstring or string_view which you want to decode
Returns
decoded data
Exceptions
basen::Exception(LENGTH)if not enough allocated length
basen::Exception(OUT_OF_ALPH)if out of digits map
basen::Exception(PADDING)if incorrect padding

Variable Documentation

◆ digits

const char base64::digits[65]
extern

◆ map

const uint8_t base64::map[256]
extern