Ditto 4.8.0-rc.2
Loading...
Searching...
No Matches
base64.hpp
1/*
2 Note that this has been slightly modified from the original version,
3 primarily in the way shown here:
4 https://stackoverflow.com/a/13935718/2041080. Extra functionality to ease
5 working with padding has also been added.
6
7 base64.cpp and base64.h
8
9 base64 encoding and decoding with C++. More information at
10 https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp
11
12 Version: 2.rc.09 (release candidate)
13
14 Copyright (C) 2004-2017, 2020-2022 René Nyffenegger
15
16 This source code is provided 'as-is', without any express or implied
17 warranty. In no event will the author be held liable for any damages arising
18 from the use of this software.
19
20 Permission is granted to anyone to use this software for any purpose,
21 including commercial applications, and to alter it and redistribute it
22 freely, subject to the following restrictions:
23
24 1. The origin of this source code must not be misrepresented; you must not
25 claim that you wrote the original source code. If you use this source code
26 in a product, an acknowledgment in the product documentation would be
27 appreciated but is not required.
28
29 2. Altered source versions must be plainly marked as such, and must not be
30 misrepresented as being the original source code.
31
32 3. This notice may not be removed or altered from any source distribution.
33
34 René Nyffenegger rene.nyffenegger@adp-gmbh.ch
35
36*/
37
38#ifndef _BASE64_H_
39#define _BASE64_H_
40
41#include <string>
42#include <vector>
43typedef unsigned char BYTE;
44
45enum class Base64PaddingType {
46 Padded,
47 Unpadded,
48};
49
50std::string base64_encode(BYTE const *buf, unsigned int buf_len,
51 Base64PaddingType padding_type);
52std::vector<BYTE> base64_decode(std::string const &);
53std::string pad_base64_encoded_string(std::string const &unpadded_string);
54
55#endif