-
Notifications
You must be signed in to change notification settings - Fork 125
Expand file tree
/
Copy pathBadString.cpp
More file actions
34 lines (30 loc) · 804 Bytes
/
BadString.cpp
File metadata and controls
34 lines (30 loc) · 804 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
#include "BadString.h"
std::string BadString::Base64decode(std::string szBase64String, LPDWORD lpdwLen)
{
DWORD dwLen;
DWORD dwNeed;
PBYTE lpBuffer = NULL;
dwLen = szBase64String.length();
dwNeed = 0;
CryptStringToBinaryA(szBase64String.c_str(), 0, CRYPT_STRING_BASE64, NULL, &dwNeed, NULL, NULL);
if (dwNeed)
{
lpBuffer = new BYTE[dwNeed + 1];
ZeroMemory(lpBuffer, dwNeed + 1);
CryptStringToBinaryA(szBase64String.c_str(), 0, CRYPT_STRING_BASE64, lpBuffer, &dwNeed, NULL, NULL);
*lpdwLen = dwNeed;
}
return std::string((PCHAR)lpBuffer);
}
BadString::BadString(std::string szInStr)
{
this->dwStrLength = szInStr.length();
this->szOutStr = this->Base64decode(szInStr, &this->dwStrLength);
}
BadString::operator std::string()
{
return this->szOutStr;
}
BadString::~BadString()
{
}