5MP Motion Camera JPEG Image and Movie Catcher  1.1.1.1
A CGI interface to capture and display pictures and movies using OpenCV.
base64.hpp
Go to the documentation of this file.
1 /*
2  * File: base64.h
3  * --------------
4  * This file declares a set of functions for encoding and decoding binary data
5  * in the base64 format. See:
6  * http://en.wikipedia.org/wiki/Base64
7  *
8  * @author Marty Stepp, based upon open-source Apache Base64 en/decoder
9  * @version 2014/08/03
10  * @since 2014/08/03
11  */
12 
13 /*
14  Copyright (c) 2020 Patrick Moffitt
15 
16  Permission is hereby granted, free of charge, to any person obtaining a copy
17  of this software and associated documentation files (the "Software"), to deal
18  in the Software without restriction, including without limitation the rights
19  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20  copies of the Software, and to permit persons to whom the Software is
21  furnished to do so, subject to the following conditions:
22 
23  The above copyright notice and this permission notice shall be included in all
24  copies or substantial portions of the Software.
25 
26  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  SOFTWARE.
33 */
34 
35 #ifndef BASE64_HPP
36 #define BASE64_HPP
37 
38 #include <cstring>
39 #include <iostream>
40 #include <fstream>
41 #include <sstream>
42 #include <string>
43 
44 using namespace std;
45 
46 class Base64 {
47 public:
48 
49  static int encode_len(int len);
50 
51  static int encode(char *coded_dst, const unsigned char *plain_src, int len_plain_src);
52 
53  static unsigned int decode_len(const char *buf_coded);
54 
55  static unsigned int decode(char *buf_plain, const char *buf_coded);
56 
57  static string encode(const std::string &s);
58 
59  static string decode(const std::string &s);
60 };
61 
62 #endif //BASE64_HPP
Definition: base64.hpp:46