I'm reading the bytes of a file (an image) to then convert into base64.
The bytes get written into a char vector called buffer, since I haven't found working examples for writing the bytes from the file into a char array
I do the char vector like such:
ifstream infile("image.png", ios_base::binary);
infile.seekg(0, ios_base::end);
size_t length = infile.tellg();
infile.seekg(0, ios_base::beg);
vector<char> buffer;
buffer.reserve(length);
copy(istreambuf_iterator<char>(infile),
istreambuf_iterator<char>(),
back_inserter(buffer)); infile.read(&buffer[0], length);
The base64 encoding function is:
int base64_encode(unsigned char *source, size_t sourcelen, char *target, size_t targetlen);
I need to send the base64 encoded text to a website, so that it can be displayed on a page for example.