Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
base64.h File Reference

Standard base64 (RFC 4648 §4), the encoding a JSON request body uses to carry bytes. More...

#include <cstdint>
#include <expected>
#include <span>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for base64.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  mm
 
namespace  mm::core
 

Functions

std::string mm::core::base64Encode (std::span< const uint8_t > bytes)
 Encodes bytes as base64 with padding, on one line.
 
std::expected< std::vector< uint8_t >, std::string > mm::core::base64Decode (std::string_view text)
 Decodes base64 text.
 

Detailed Description

Standard base64 (RFC 4648 §4), the encoding a JSON request body uses to carry bytes.

JSON has no binary type, so anything that must travel as a value rather than as a whole request body — a firmware package inside a procedure's parameters, say — is base64 in a string. This is the plain alphabet with + and / and mandatory = padding; the URL-safe variant is not supported because nothing here puts base64 in a URL.