include boost archive iterators base64_from_binary hpp include boost a

 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
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <fstream>
#include <iostream>
using namespace std;
typedef
boost::archive::iterators::base64_from_binary<
boost::archive::iterators::transform_width<const char*, 6, 8>
> base64_t;
int main() {
ifstream f("/tmp/a.txt");
f.seekg(0, std::ios_base::end);
int len = f.tellg();
f.seekg(0, std::ios_base::beg);
char* data = new char[len];
f.read(data, len);
f.close();
string enc(base64_t(data), base64_t(data+len));
cout << enc << endl;
return 0;
}