19namespace Azure {
namespace Core {
44 static std::string
Base64Encode(
const std::vector<uint8_t>& data);
52 static std::vector<uint8_t>
Base64Decode(
const std::string& text);
79 static std::string Base64Encode(
const std::string& data);
86 class Base64Url final {
89 static std::string Base64UrlEncode(
const std::vector<uint8_t>& data)
93 auto trail = base64.find(
'=');
94 if (trail != std::string::npos)
96 base64 = base64.substr(0, trail);
98 std::replace(base64.begin(), base64.end(),
'+',
'-');
99 std::replace(base64.begin(), base64.end(),
'/',
'_');
103 static std::vector<uint8_t> Base64UrlDecode(
const std::string& text)
105 std::string base64url(text);
107 std::replace(base64url.begin(), base64url.end(),
'-',
'+');
108 std::replace(base64url.begin(), base64url.end(),
'_',
'/');
109 switch (base64url.size() % 4)
114 base64url.append(
"==");
117 base64url.append(
"=");
120 throw std::invalid_argument(
"Unexpected Base64URL encoding in the HTTP response.");
Used to convert one form of data into another, for example encoding binary data into Base64 encoded o...
Definition base64.hpp:28
static std::string Base64Encode(const std::vector< uint8_t > &data)
Encodes a vector of binary data using Base64.
Definition base64.cpp:483
static std::vector< uint8_t > Base64Decode(const std::string &text)
Decodes a Base64 encoded data into a vector of binary data.
Definition base64.cpp:488
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57