userver: crypto::base64 Namespace Reference
Loading...
Searching...
No Matches
crypto::base64 Namespace Reference

Detailed Description

Cryptographic hashing, base64 encoding and decoding helpers.

Enumerations

enum class  Pad {
  kWith ,
  kWithout
}

Functions

std::string Base64Encode (std::string_view data, Pad pad=Pad::kWith)
 Encodes data to Base64, add padding by default.
std::string Base64Decode (std::string_view data)
 Decodes data from Base64, padding is optional, line breaks are skipped, unused bits of the last character are ignored.
std::string Base64UrlEncode (std::string_view data, Pad pad=Pad::kWith)
 Encodes data to Base64 (using URL alphabet), add padding by default.
std::string Base64UrlDecode (std::string_view data)
 Decodes data from Base64 (using URL alphabet), padding is optional, line breaks are skipped, unused bits of the last character are ignored.
bool Base64UniversalDecodeInPlace (std::string &data) noexcept
 Decodes data in-place and returns true on success.

Enumeration Type Documentation

◆ Pad

enum class crypto::base64::Pad
strong

Definition at line 15 of file base64.hpp.

Function Documentation

◆ Base64Decode()

std::string crypto::base64::Base64Decode ( std::string_view data)

Decodes data from Base64, padding is optional, line breaks are skipped, unused bits of the last character are ignored.

Exceptions
CryptoExceptionif data contains other characters outside of the alphabet (including spaces and the URL alphabet), '=' not at the end, more than two '=' or if the number of characters before '=' is 1 modulo 4

◆ Base64Encode()

std::string crypto::base64::Base64Encode ( std::string_view data,
Pad pad = Pad::kWith )

Encodes data to Base64, add padding by default.

Parameters
databinary data to encode
padcontrols if pad should be added or not
Exceptions
CryptoExceptioninternal library exception

◆ Base64UniversalDecodeInPlace()

bool crypto::base64::Base64UniversalDecodeInPlace ( std::string & data)
nodiscardnoexcept

Decodes data in-place and returns true on success.

Note
Supports both traditional and "web-safe" base64 encodings.

◆ Base64UrlDecode()

std::string crypto::base64::Base64UrlDecode ( std::string_view data)

Decodes data from Base64 (using URL alphabet), padding is optional, line breaks are skipped, unused bits of the last character are ignored.

Exceptions
CryptoExceptionif data contains other characters outside of the URL alphabet (including spaces and the standard alphabet), '=' not at the end, more than two '=' or if the number of characters before '=' is 1 modulo 4

◆ Base64UrlEncode()

std::string crypto::base64::Base64UrlEncode ( std::string_view data,
Pad pad = Pad::kWith )

Encodes data to Base64 (using URL alphabet), add padding by default.

Parameters
databinary data to encode
padcontrols if pad should be added or not
Exceptions
CryptoExceptioninternal library exception