Skip to content

ST::base64

Michael Hansen edited this page Jan 6, 2018 · 3 revisions

string_theory base64 codec

Headers

#include <string_theory/codecs>

Public Functions

Name Summary
ST::base64_encode Encode a sequence of bytes as Base64
ST::base64_decode Decode a Base64 string into a sequence of bytes

Function Documentation

ST::base64_decode

Signature
ST::char_buffer ST::base64_decode(const ST::string &base64) (1)
ST_ssize_t ST::base64_decode(const ST::string &base64, void *output, size_t output_size) noexcept (2)
  1. Decode the base64 string in base64 to a buffer. If the input string contains invalid base64 data, an ST::codec_error is thrown with a message indicating the type of failure.

  2. If output is NULL, this function ignores output_size and returns the necessary size to store the entire decoded data from base64. If the data in base64 is not correctly padded, this will return -1 instead. However, no further checking of the input is done in this mode.

    If output is not NULL, this will convert the base64 data in base64 and write it to output. If output_size is too small for the entire conversion, or if any part of the conversion fails, this will return -1 and output will be left in an indeterminate state.


ST::base64_encode

Signature
ST::string ST::base64_encode(const void *data, size_t size) (1)
ST::string ST::base64_encode(const ST::char_buffer &data) (2)
  1. Encode the first size bytes of data to a Base64 string representation. If size is 0, data may be NULL; otherwise, data must be non-NULL.
  2. Encode all data stored in data to a Base64 string representation.
Clone this wiki locally