diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:08:11 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:19:30 +0200 |
| commit | df56d2eb26b34b0af590f3aedfda7896f4b103dd (patch) | |
| tree | f58c38e7ed25c2cec3f0fc16d7c8a75806c0d569 /src/base64.hh | |
| parent | 800bdbb18617dfac36067b8841781a92b19d57c1 (diff) | |
base64: Add new module
Encodes and decodes base64. No linebreaks, always padding.
Diffstat (limited to 'src/base64.hh')
| -rw-r--r-- | src/base64.hh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/base64.hh b/src/base64.hh new file mode 100644 index 0000000..491755c --- /dev/null +++ b/src/base64.hh @@ -0,0 +1,25 @@ +#ifndef BASE64_HH +#define BASE64_HH + +#include <cstdint> +#include <optional> +#include <span> +#include <string> +#include <vector> + +namespace base64 { + +[[nodiscard]] +std::string encode(std::span<uint8_t const> data); + +void encode(std::span<uint8_t const> in, std::string& out); + +[[nodiscard]] +std::optional<std::vector<uint8_t>> decode(std::string_view value); + +[[nodiscard]] +bool decode(std::string_view in, std::vector<uint8_t>& out); + +} // namespace base64 + +#endif // BASE64_HH |
