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 <C_CkBinData.h>
void ChilkatSample(void)
{
BOOL success;
HCkBinData bd;
success = FALSE;
bd = CkBinData_Create();
success = CkBinData_LoadFile(bd,"qa_data/jpg/starfish.jpg");
if (success == FALSE) {
printf("Failed to load file.\n");
CkBinData_Dispose(bd);
return;
}
printf("%s\n",CkBinData_getEncoded(bd,"base64"));
// If you want mult-line base64:
printf("--\n");
printf("%s\n",CkBinData_getEncoded(bd,"base64_mime"));
// If you want hex..
printf("--\n");
printf("%s\n",CkBinData_getEncoded(bd,"hex"));
// etc.
CkBinData_Dispose(bd);
}