-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (23 loc) · 991 Bytes
/
main.cpp
File metadata and controls
31 lines (23 loc) · 991 Bytes
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
#include <string>
#include "tomcrypt.h"
using namespace std;
int32_t main(int32_t argc, char** argv) {
std::string str = "this is a test data this is a test data this is a test data";
const size_t bufszie = 1024;
unsigned char in_buf[bufszie];
unsigned long in_bufszie;
unsigned char out_buf[bufszie];
unsigned long out_bufszie;
// base64
in_bufszie = str.size();
memcpy(in_buf, str.data(), in_bufszie);
int ret = base64_encode(in_buf, in_bufszie, out_buf, &(out_bufszie = bufszie));
printf("base64_encode ret:%d, out_bufszie:%lu, out_buf:%s\n",
ret, out_bufszie, std::string(reinterpret_cast<char*>(out_buf), out_bufszie).c_str());
in_bufszie = out_bufszie;
memcpy(in_buf, out_buf, in_bufszie);
ret = base64_decode(in_buf, in_bufszie, out_buf, &(out_bufszie = bufszie));
printf("base64_encode ret:%d, out_bufszie:%lu, out_buf:%s\n",
ret, out_bufszie, std::string(reinterpret_cast<char*>(out_buf), out_bufszie).c_str());
return 0;
}