int DecodeBase64(unsigned char *sSour,unsigned char *sDest,int iLen)

来源(arithdon)

From: http://blog.chinaunix.net/u/2502/showart_7762.html

int DecodeBase64(unsigned char *sSour,unsigned char *sDest,int iLen) {
    char *sBase64Alphabet={"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"};
    unsigned char sVal;
    unsigned int i,j,iStorage,iCount,k=0;
    iStorage = 0;
    iCount = 0;
    for(i=0;i<iLen;i++) {
        if(sSour[i]!='=') {
            for(j=0;j<strlen(sBase64Alphabet);j++) {
                if(sSour[i]==sBase64Alphabet[j]) {
                    sVal = j;
                    iCount += 6;
                    break;
                }
            }
        } else
            sVal = 0;
        iStorage = (iStorage<<6)|sVal;
        if((i+1)%4==0) {
            sDest[k++] = iStorage>>16;
            sDest[k++] = (iStorage>>8)&0x0ff;
            sDest[k++] = iStorage&0x0ff;
            iStorage = 0;
        }
    }
    iCount = iCount/8;
    return(iCount);
}

Link: http://www.asm32.net/article_details.aspx?id=4332


浏览次数 78 发布时间 2008/12/2 15:54:32 从属分类 ARITHMETIC 【评论】【 】【打印】【关闭
 
| www.asm32.net | 2006版 | 资料中心 | linux | asm/asm32 | C/C++ | VC++ | java | Python | 书签 | ASP.Net书签 | 京ICP备09029108号-1