The Battle for Wesnoth  1.19.5+dev
base64.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 #include <cstdint>
19 #include <string>
20 #include <string_view>
21 #include <vector>
22 
23 namespace utils
24 {
25 using byte_string_view = std::basic_string_view<uint8_t>;
26 }
27 
28 // Official Base64 encoding (RFC4648)
29 namespace base64 {
30  std::vector<uint8_t> decode(std::string_view encoded);
31  std::string encode(utils::byte_string_view bytes);
32 }
33 // crypt()-compatible radix-64 encoding
34 namespace crypt64 {
35  std::vector<uint8_t> decode(std::string_view encoded);
36  std::string encode(utils::byte_string_view bytes);
37  // Single character functions. For special use only
38  int decode(char encoded_char);
39  char encode(int value);
40 }
std::string encode(utils::byte_string_view bytes)
Definition: base64.cpp:225
std::vector< uint8_t > decode(std::string_view in)
Definition: base64.cpp:221
std::string encode(utils::byte_string_view bytes)
Definition: base64.cpp:235
std::vector< uint8_t > decode(std::string_view in)
Definition: base64.cpp:231
std::basic_string_view< uint8_t > byte_string_view
Definition: base64.hpp:25