void decode(const char* pSrc, int src_len, unsigned char* pDst,int * outl)
{
int nValue;   
nValue = DeBase64Tab[*pSrc++] << 18;
nValue += DeBase64Tab[*pSrc++] << 12;
*pDst++ = (nValue & 0x00ff0000) >> 16;

解决方案 »

  1.   

    不过是个最简单的查表Base64转换代码而已,大意就是下面的意思,编译不一定能通过,我手工敲的,没验证.其实这个方式转Base64是一种效率比较低的.还有很过更高效的.
    const
      DeBase64Tab : array[AnsiChar] of AnsiChar = (XX,XX,XX这里就是Base64的编码表);procedure decode(pSrc :PAnsiChar; src_Len : Integer;  pDst : Pointer; var outl : Integer);
    var
      nValue : Integer;
    begin
      nValue := Ord(DeBase64Tab[pSrc^]) shl 18;
      Inc(pSrc);
      Inc(nValue, Ord(DeBase64Tab[pSrc^]) shl 12);
      Inc(pSrc);
      PAnsiChar(pDst)^ := AnsiChar((nValue and $00ff0000) shr 16);
      Inc(PAnsiChar(pDst));
    end;
      

  2.   

      procedure decode(const pSrc: PAnsiChar; src_len: Integer;
                       pDst: PByte; out1: PInteger);
      var 
        pTmpSrc: PAnsiChar;
        pTmpDst: PByte;
        nValue: Integer;
      begin
        pTmpSrc := pSrc;
        pTmpDst := pDst;
        nValue := DeBase64Tab[Ord(pTmpSrc^)] shl 18;
        inc(pTmpSrc);
        inc(nValue, DeBase64Tab[Ord(pTmpSrc^)] shl 12);
        inc(pTmpSrc); 
        pTmpDst^ := Byte((nValue and $ff0000) shr 16);
        inc(pTmpDst);  
      end;