-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcryptohelper.cpp
More file actions
37 lines (32 loc) · 858 Bytes
/
cryptohelper.cpp
File metadata and controls
37 lines (32 loc) · 858 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
32
33
34
35
36
#include "cryptohelper.h"
cryptohelper::cryptohelper()
{
}
cryptohelper::~cryptohelper()
{
}
std::string cryptohelper::base64_encode(std::string source) {
string encoded;
if (source == "")return "";
Base64::Encode(source, &encoded);
return encoded;
}
std::string cryptohelper::base64_decode(std::string source) {
string decoded;
if (source == "")return "";
//MessageBox(NULL, _T("提示信息"), _T("提示信息3"), MB_OK);
Base64::Decode(source, &decoded);
//MessageBox(NULL, _T("提示信息"), _T("提示信息4"), MB_OK);
return decoded;
}
string cryptohelper::rot13(std::string source) {
string out;
for (string::iterator it = source.begin(); it != source.end(); it++) {
if (*it >= 'a'&&*it <= 'z')
out += (*it - 'a' + 13) % 26 + 'a';
else if (*it >= 'A'&&*it <= 'Z')
out += (*it - 'A' + 13) % 26 + 'A';
else out += *it;
}
return out;
}