C
Chunekit Pong
What's the problem with this code?
the purpose is to convert binary file into a Base64 string
I seem to have problem in the following line
BYTE const* pbBinary = &bytes[0];
int size = sizeof(pbBinary);
=================
typedef unsigned char BYTE;
std::ifstream file1("c:/test2.png");
// read from test2.png into BYTE array
std::vector<BYTE> bytes(
(std::istreambuf_iterator<char>(file1))
, (std::istreambuf_iterator<char>())
);
if(bytes.empty())
; // no bytes have been read
BYTE const* pbBinary = &bytes[0];
int size = sizeof(pbBinary);
unsigned long ulEncLen = 0;
char *pEncOut = NULL;
BOOL fRet = ::CryptBinaryToString( pbBinary, size,
CRYPT_STRING_BASE64, pEncOut, &ulEncLen );
====================
BOOL WINAPI CryptBinaryToString(
__in const BYTE *pbBinary,
__in DWORD cbBinary,
__in DWORD dwFlags,
__out_opt LPTSTR pszString,
__inout DWORD *pcchString
);
the purpose is to convert binary file into a Base64 string
I seem to have problem in the following line
BYTE const* pbBinary = &bytes[0];
int size = sizeof(pbBinary);
=================
typedef unsigned char BYTE;
std::ifstream file1("c:/test2.png");
// read from test2.png into BYTE array
std::vector<BYTE> bytes(
(std::istreambuf_iterator<char>(file1))
, (std::istreambuf_iterator<char>())
);
if(bytes.empty())
; // no bytes have been read
BYTE const* pbBinary = &bytes[0];
int size = sizeof(pbBinary);
unsigned long ulEncLen = 0;
char *pEncOut = NULL;
BOOL fRet = ::CryptBinaryToString( pbBinary, size,
CRYPT_STRING_BASE64, pEncOut, &ulEncLen );
====================
BOOL WINAPI CryptBinaryToString(
__in const BYTE *pbBinary,
__in DWORD cbBinary,
__in DWORD dwFlags,
__out_opt LPTSTR pszString,
__inout DWORD *pcchString
);