-
Notifications
You must be signed in to change notification settings - Fork 3
/
base64.h
51 lines (39 loc) · 1.46 KB
/
base64.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
/**
--------------------------------------------------------------------------------
- Module : base64.h
- Description : Just another Base64 encoding/decoding class
- Author : Tim Zaman, 18-FEB-2016
--------------------------------------------------------------------------------
*/
/*
Copyright (c) 2016 Tim Zaman
Permission to use, copy, modify, distribute, and sell this software
for any purpose is hereby granted without fee, provided
that (i) the above copyright notices and this permission notice appear in
all copies of the software and related documentation.
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef BASE64_TIM_H
#define BASE64_TIM_H
#include <iostream>
#include <stdint.h>
#include <stdlib.h>
#include <string>
class b64 {
public:
b64();
~b64();
std::string base64_encode(unsigned char const* , unsigned int len);
std::string base64_encode(std::string);
std::string base64_decode(char const* , unsigned int len);
std::string base64_decode(std::string);
private:
char *decoding_table = NULL;
void base64_cleanup();
void build_decoding_table();
char * base64_encode(const unsigned char *data, unsigned int input_length, unsigned int *output_length);
unsigned char * base64_decode(const char *data, unsigned int input_length, unsigned int *output_length);
};
#endif