Because vc6 does not have the base64 API, this is only for vc6, and vc6 and later versions all have their own APIs. This is also directly copied from the API to ensure it can be used. It is not very useful to find a few on the Internet.
Inline int decodebase64char (unsigned int ch) Throw () {// returns-1 if the character is invalid // or shocould be skipped // otherwise, returns the 6-bit code for the character // from the encoding tableif (CH> = 'A' & Ch <= 'Z') return ch-'A' + 0; // 0 range starts at 'A' if (CH> = 'A' & Ch <= 'Z') return ch-'A' + 26; // 26 range starts at 'A' if (CH> = '0' & Ch <= '9') return ch-'0' + 52; // 52 range Starts at '0' if (CH = '+') return 62; If (CH = '/') return 63; Return-1 ;} inline bool base64decode (lpcstr szsrc, int nsclen, byte * pbdest, int * pndestlen) Throw () {// walk the source buffer // each four character sequence is converted to 3 bytes // crlfs and =, and any characters not in the encoding table // are skipedif (szsrc = NULL | pndestlen = NULL) {atlassert (false); Return false;} lpcstr szsrcen D = szsrc + nsclen; int nwritten = 0; bool boverflow = (pbdest = NULL )? True: false; while (szsrc <szsrcend & (* szsrc )! = 0) {DWORD dwcurr = 0; int I; int nbits = 0; for (I = 0; I <4; I ++) {If (szsrc> = szsrcend) break; int NCH = decodebase64char (* szsrc); szsrc ++; If (NCH =-1) {// skip this Chari --; continue;} dwcurr <= 6; dwcurr | = NCH; nbits + = 6;} If (! Boverflow & nwritten + (nbits/8)> (* pndestlen) boverflow = true; // dwcurr has the 3 bytes to write to the output buffer // left to rightdwcurr <= 24-nbits; for (I = 0; I <nbits/8; I ++) {If (! Boverflow) {* pbdest = (byte) (dwcurr & 0x00ff0000)> 16); pbdest ++;} dwcurr <= 8; nwritten ++ ;}} * pndestlen = nwritten; If (boverflow) {If (pbdest! = NULL) {atlassert (false);} return false;} return true ;}
Directly call base64decode