-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathencode.h
75 lines (66 loc) · 2.41 KB
/
encode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// encode.h - encoding/decoding interface
//
// leccore library, part of the liblec library
// Copyright (c) 2019 Alec Musasa (alecmus at live dot com)
//
// Released under the MIT license. For full details see the
// file LICENSE.txt
//
#pragma once
#if defined(LECCORE_EXPORTS)
#include "leccore.h"
#else
#include <liblec/leccore.h>
#endif
#include <string>
namespace liblec {
namespace leccore {
/// <summary>Base32 encoding/decoding class.</summary>
class leccore_api base32 {
public:
/// <summary>Get the default base32 encoding alphabet
/// used by the <see cref="base32"></see> class.</summary>
/// <returns>The default alphabet.</returns>
[[nodiscard]]
static const std::string default_alphabet();
/// <summary>Encode to base32.</summary>
/// <param name="input">The data to be encoded.</param>
/// <param name="alphabet">The alphabet to use for the encoding.</param>
/// <returns>The encoded result.</returns>
[[nodiscard]]
static std::string encode(const std::string& input,
std::string alphabet = default_alphabet());
/// <summary>Decode from base32.</summary>
/// <param name="input">The data to be decoded.</param>
/// <param name="alphabet">The alphabet to use for the decoding.</param>
/// <returns>The decoded result.</returns>
[[nodiscard]]
static std::string decode(const std::string& input,
std::string alphabet = default_alphabet());
};
/// <summary>Base64 encoding/decoding class.</summary>
class leccore_api base64 {
public:
/// <summary>Get the default base64 encoding alphabet
/// used by the <see cref="base64"></see> class.</summary>
/// <returns>The default alphabet.</returns>
[[nodiscard]]
static const std::string default_alphabet();
/// <summary>Encode to base64.</summary>
/// <param name="input">The data to be encoded.</param>
/// <param name="alphabet">The alphabet to use for the encoding.</param>
/// <returns>The encoded result.</returns>
[[nodiscard]]
static std::string encode(const std::string& input,
std::string alphabet = default_alphabet());
/// <summary>Decode from base64.</summary>
/// <param name="input">The data to be decoded.</param>
/// <param name="alphabet">The alphabet to use for the decoding.</param>
/// <returns>The decoded result.</returns>
[[nodiscard]]
static std::string decode(const std::string& input,
std::string alphabet = default_alphabet());
};
}
}