C++
C++
Get Contents of File as Base64
See more Encryption Examples
Demonstrates how to read the contents of a file and convert to a base64 string.Chilkat C++ Downloads
#include <CkBinData.h>
void ChilkatSample(void)
{
bool success = false;
CkBinData bd;
success = bd.LoadFile("qa_data/jpg/starfish.jpg");
if (success == false) {
std::cout << "Failed to load file." << "\r\n";
return;
}
std::cout << bd.getEncoded("base64") << "\r\n";
// If you want mult-line base64:
std::cout << "--" << "\r\n";
std::cout << bd.getEncoded("base64_mime") << "\r\n";
// If you want hex..
std::cout << "--" << "\r\n";
std::cout << bd.getEncoded("hex") << "\r\n";
// etc.
}