userver: userver/crypto/base64.hpp Source File
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
base64.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/crypto/base64.hpp
4/// @brief @copybrief crypto::base64
5/// @ingroup userver_universal
6
7#include <string_view>
8
9USERVER_NAMESPACE_BEGIN
10
11/// Cryptographic hashing
12namespace crypto::base64 {
13
14enum class Pad { kWith, kWithout };
15
16/// @brief Encodes data to Base64, add padding by default
17/// @param data binary data to encode
18/// @param pad controls if pad should be added or not
19/// @throws CryptoException internal library exception
20std::string Base64Encode(std::string_view data, Pad pad = Pad::kWith);
21
22/// @brief Decodes data from Base64
23/// @throws CryptoException internal library exception
24std::string Base64Decode(std::string_view data);
25
26#ifndef USERVER_NO_CRYPTOPP_BASE64_URL
27
28/// @brief Encodes data to Base64 (using URL alphabet), add padding by default
29/// @param data binary data to encode
30/// @param pad controls if pad should be added or not
31/// @throws CryptoException internal library exception
32std::string Base64UrlEncode(std::string_view data, Pad pad = Pad::kWith);
33
34/// @brief Decodes data from Base64 (using URL alphabet)
35/// @throws CryptoException internal library exception
36std::string Base64UrlDecode(std::string_view data);
37
38#endif
39
40} // namespace crypto::base64
41
42USERVER_NAMESPACE_END