2016-12-29 259 views
0

我有一个表示图像的unsigned char数组,我想在网页中显示它。将unsigned char数组转换为base64字符串

我从ActiveX控件数组,我想表明它使用JavaScript我的网页,所以我必须为“的base64字符串”转换,所以我的问题是

如何为unsigned char转换数组到base64字符串在c + +?

+1

退房http://stackoverflow.com/questions/342409/how-do-i-base64-encode-decode-in-c – pSoLT

回答

0

苹果已经发布了一个开源的Base64编码/解码器。我记得有一次在Windows项目上没有问题的编译。来源here。标题here

例如:

unsigned char* array = <your data>; 
int len = <number of bytes in "array"> 

int max_encoded_length = Base64encode_len(len); 
char* encoded = new char[max_encoded_length]; 

int result = Base64encode(encoded, (const char *)array, len); 

// encoded is now a null terminated b64 string 
// "result" is the length of the string *including* the null terminator 
// don't forget to invoke "delete [] encoded" when done