-
Notifications
You must be signed in to change notification settings - Fork 0
/
base64_encoder.h
36 lines (29 loc) · 976 Bytes
/
base64_encoder.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
#ifndef UC_BASE64_ENCODER_H__
#define UC_BASE64_ENCODER_H__
#include <string>
namespace uc {
/**
* \breif Encoder of base64 coding
*
* Currently, this is a empty class
* For scalability, I define it be a class
*/
class Base64Encoder {
public:
Base64Encoder() = default;
~Base64Encoder() = default;
/**
* \param[in] raw Raw format data, i.e. native binary
* \param[out] text Store the ascii ocde translated from raw
* \param new_line Put a newline to the \p text every 64 character(inspired by openssl enc), if the last line does not hold 64 bytes, put a newline character also
*/
void Encode(void const *raw, size_t len, std::string &text, bool newline=true);
/**
* \param[in] filename the name of the file store the raw format data
* \param[out] text like Encode()
* \param new_line like Encode()
*/
void EncodeFromFile(char const *filename, std::string &text, bool newline=true);
};
} // uc
#endif // UC_BASE64_ENCODER_H__