how to convert array of bytes to base64 String in iphone?

前端 未结 6 1991
忘掉有多难
忘掉有多难 2021-02-15 09:20

I have a piece of code in vb. I need to convert array of bytes to base 64 string. Following is the vb code.

If arrLicence.Count > 0 Then

LicenceByt

6条回答
  •  粉色の甜心
    2021-02-15 09:47

    unsigned char *buffer = (unsigned char*)malloc(8);
    buffer[0] =  [d1 bytes]  ;
    buffer[1] =  [d2 bytes] ;
    buffer[2] =  [d3 bytes] ;
    buffer[3] =  [d4 bytes] ;
    

    Not sure what you expect this to do. bytes return an array, and you are assigning the addresses of the arrays to char elements of your buffer. This buffer won't be filled with any of the data you expect, and the "data" from d2 will partially overwrite those from d1 etc.

    Also, you shouldn't make much assumptions about the lengths of your byte arrays, especially not if using UTF-16.

    In a word: You don't throw the data you expect at your conversion routine. Maybe check that in the debugger.

提交回复
热议问题