2016-12-29 356 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 
相關問題