libkeepass 0.2.0
KeePass key database importer/exporter library
Loading...
Searching...
No Matches
base64.hh File Reference

Base64 encoding and decoding helpers. More...

#include <algorithm>
#include <locale>
#include <string>
#include <string_view>
#include <type_traits>
#include "exception.hh"

Go to the source code of this file.

Functions

template<typename InputIterator >
std::string keepass::base64_encode (InputIterator first, InputIterator last)
 Encodes a range of bytes into a base64 string.
 
template<typename OutputIterator , typename Type >
void keepass::base64_decode (std::string_view src, OutputIterator result)
 Decodes a base64 string into an output sequence.
 
std::string keepass::base64_encode (const std::string &src)
 Convenience overload that encodes an entire std::string.
 
std::string keepass::base64_decode (std::string_view src)
 Convenience overload that decodes a base64 string into a std::string.
 

Detailed Description

Base64 encoding and decoding helpers.

Function Documentation

◆ base64_decode()

template<typename OutputIterator , typename Type >
void keepass::base64_decode ( std::string_view  src,
OutputIterator  result 
)

Decodes a base64 string into an output sequence.

Template Parameters
OutputIteratorthe output iterator type receiving the decoded bytes.
Typethe value type written to the output iterator.
Parameters
srcthe base64 string to decode.
resultoutput iterator receiving the decoded bytes.
Exceptions
FormatErrorif the input is not valid base64.

◆ base64_encode()

template<typename InputIterator >
std::string keepass::base64_encode ( InputIterator  first,
InputIterator  last 
)

Encodes a range of bytes into a base64 string.

Template Parameters
InputIteratorthe iterator type over the input bytes.
Parameters
firstbegin iterator of the byte range.
lastend iterator of the byte range.
Returns
the base64-encoded string.