-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseXX.cpp
More file actions
79 lines (66 loc) · 2.13 KB
/
BaseXX.cpp
File metadata and controls
79 lines (66 loc) · 2.13 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// BaseXX.cpp
// desTest
//
// Created by ksoo k on 13. 4. 19..
//
//
#include "BaseXX.h"
#include <sstream>
#include <vector>
std::vector<char> base2To(const std::string& t)
{
std::ostringstream oss(std::stringstream::out | std::stringstream::in | std::stringstream::binary);
std::ostreambuf_iterator<char> out(oss);
stlencoders::base2<char>::decode(t.begin(), t.end(), out);
std::istreambuf_iterator<char> itt(oss.rdbuf()), eos;
std::vector<char> serialVector;
serialVector.reserve(60); // just a guess
while(itt != eos) {
char c = *itt++;
serialVector.push_back(c);
}
return serialVector;
}
std::vector<char> base16To(const std::string& t)
{
std::ostringstream oss(std::stringstream::out | std::stringstream::in | std::stringstream::binary);
std::ostreambuf_iterator<char> out(oss);
stlencoders::base16<char>::decode(t.begin(), t.end(), out);
std::istreambuf_iterator<char> itt(oss.rdbuf()), eos;
std::vector<char> serialVector;
serialVector.reserve(60); // just a guess
while(itt != eos) {
char c = *itt++;
serialVector.push_back(c);
}
return serialVector;
}
std::vector<char> base32To(const std::string& t)
{
std::ostringstream oss(std::stringstream::out | std::stringstream::in | std::stringstream::binary);
std::ostreambuf_iterator<char> out(oss);
stlencoders::base32<char>::decode(t.begin(), t.end(), out);
std::istreambuf_iterator<char> itt(oss.rdbuf()), eos;
std::vector<char> serialVector;
serialVector.reserve(60); // just a guess
while(itt != eos) {
char c = *itt++;
serialVector.push_back(c);
}
return serialVector;
}
std::vector<char> base64To(const std::string& t)
{
std::ostringstream oss(std::stringstream::out | std::stringstream::in | std::stringstream::binary);
std::ostreambuf_iterator<char> out(oss);
stlencoders::base64<char>::decode(t.begin(), t.end(), out);
std::istreambuf_iterator<char> itt(oss.rdbuf()), eos;
std::vector<char> serialVector;
serialVector.reserve(60); // just a guess
while(itt != eos) {
char c = *itt++;
serialVector.push_back(c);
}
return serialVector;
}