我简单的调用CBase64中Decode(LPCTSTR szDecoding, LPTSTR szOutput ),把乱码传进去,
可是传出来的szOutput全部为0,怎么回事?

解决方案 »

  1.   

    自己写一个转换程序啊。
    Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
    *s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
    unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
    t = n_Len % 4;
    for(i = 0; i < n_Len/4; i++)
    {
    s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
    s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
    s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
    }unsigned char tail[4];  //处理尾部数据
    for(k = 0; k < 4; k++)  //置0
       tail[k] = 0;
    for(k = 0; k < t; k++)
       tail[k] = s_Coded[4*i+k];if(t > 0)
      s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
    if(t > 1)
      s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
    if(t > 2)
      s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
      

  2.   

    自己写一个转换程序啊。
    Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
    *s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
    unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
    t = n_Len % 4;
    for(i = 0; i < n_Len/4; i++)
    {
    s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
    s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
    s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
    }unsigned char tail[4];  //处理尾部数据
    for(k = 0; k < 4; k++)  //置0
       tail[k] = 0;
    for(k = 0; k < t; k++)
       tail[k] = s_Coded[4*i+k];if(t > 0)
      s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
    if(t > 1)
      s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
    if(t > 2)
      s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
      

  3.   

    自己写一个转换程序啊。
    Base64的编码方式是:将原始数据转换成二进制,然后再每6位取数据,组成一个字符。解码时反过来就行了。
    *s_Coded表示是经过编码的字符串;*s_Decode表示是输出的解过码的字符串;n_Len表示s_Coded的长度。
    unsigned short i,t,k; //t表示尾部剩余的不足4字节数据的长度。
    t = n_Len % 4;
    for(i = 0; i < n_Len/4; i++)
    {
    s_Decode[3*i] = (s_Coded[4*i] << 2) & 0xfc + (s_Coded[4*i+1] >> 4) & 0x03;
    s_Decode[3*i+1] = (s_Coded[4*i+1] << 4) & 0xf0 + (s_Coded[4*i+2] >> 2) & 0x0f;
    s_Decode[3*i+2] = (s_Coded[4*i+2] << 6) & 0xc0 + s_Coded[4*i+3] & 0x3f;
    }unsigned char tail[4];  //处理尾部数据
    for(k = 0; k < 4; k++)  //置0
       tail[k] = 0;
    for(k = 0; k < t; k++)
       tail[k] = s_Coded[4*i+k];if(t > 0)
      s_Decode[3*i] = (tail[0] << 2) & 0xfc + (tail[1] >> 4) & 0x03;
    if(t > 1)
      s_Decode[3*i+1] = (tail[1] << 4) & 0xf0 + (tail[2] >> 2) & 0x0f;
    if(t > 2)
      s_Decode[3*i+2] = (tail[2] << 6) & 0xc0 + tail[3] & 0x3f;代码写得比较粗糙,请谅解。
      

  4.   

    能给我一个吗?
    email: [email protected]
    谢谢了
      

  5.   

    上面的不是太懂,能把详细给我发一份吗?
    [email protected]