added converttobase64 function

added UploadMinidump2BM
This commit is contained in:
/dev/root
2016-08-27 18:18:03 +02:00
parent 738f9ee941
commit 6696a57b18
4 changed files with 75 additions and 2 deletions

View File

@ -115,5 +115,20 @@ namespace Utils
return fmt::sprintf("%02d:%02d:%02d", hoursTotal, minutes, seconds);
}
// Encodes a given string in Base64
std::string encodeBase64(const char* input, const unsigned long inputSize) {
unsigned long outlen = long(inputSize + (inputSize / 3.0) + 16);
unsigned char* outbuf = new unsigned char[outlen]; //Reserve output memory
base64_encode((unsigned char*)input, inputSize, outbuf, &outlen);
std::string ret((char*)outbuf, outlen);
delete[] outbuf;
return ret;
}
// Encodes a given string in Base64
std::string encodeBase64(const std::string& input) {
return encodeBase64(input.c_str(), input.size());
}
}
}

View File

@ -39,5 +39,8 @@ namespace Utils
std::string DumpHex(std::string data, std::string separator = " ");
std::string XOR(std::string str, char value);
std::string encodeBase64(const char* input, const unsigned long inputSize);
std::string encodeBase64(const std::string& input);
}
}