E-MailRelay
Static Public Member Functions | List of all members
G::Base64 Class Reference

A base64 codec class. More...

#include <gbase64.h>

Static Public Member Functions

static std::string encode (std::string_view, std::string_view line_break={})
 Encodes the given string, optionally inserting line-breaks to limit the line length. More...
 
static std::string decode (std::string_view, bool throw_on_invalid=false, bool strict=true)
 Decodes the given string. More...
 
static bool valid (std::string_view, bool strict=true)
 Returns true if the string is a valid base64 encoding, possibly allowing for embedded newlines, carriage returns, and space characters. More...
 

Detailed Description

A base64 codec class.

See also
RFC-1341 section 5.2

Definition at line 38 of file gbase64.h.

Member Function Documentation

◆ decode()

std::string G::Base64::decode ( std::string_view  s,
bool  throw_on_invalid = false,
bool  strict = true 
)
static

Decodes the given string.

Either throws an exception if not a valid() encoding, or returns the empty string.

Definition at line 84 of file gbase64.cpp.

◆ encode()

std::string G::Base64::encode ( std::string_view  s,
std::string_view  line_break = {} 
)
static

Encodes the given string, optionally inserting line-breaks to limit the line length.

Definition at line 79 of file gbase64.cpp.

◆ valid()

bool G::Base64::valid ( std::string_view  s,
bool  strict = true 
)
static

Returns true if the string is a valid base64 encoding, possibly allowing for embedded newlines, carriage returns, and space characters.

Strict checking permits one or two pad characters at the end to make a multiple of four characters in total, but no newlines, carriage returns or other odd characters. Empty strings are valid; single character strings are not.

Definition at line 89 of file gbase64.cpp.


The documentation for this class was generated from the following files: