1 #ifndef _BASE64ENCDEC_H_
2 #define _BASE64ENCDEC_H_
4 static void base64encode(const unsigned char *in
, char *out
, int len
)
6 char alphabet
[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
19 *out
++ = alphabet
[(accum
>> shift
) & 0x3F];
24 *out
++ = alphabet
[(accum
& 0xF)<<2];
29 *out
++ = alphabet
[(accum
& 0x3)<<4];
37 static int base64decode(const char *src
, unsigned char *dest
, int destsize
)
39 unsigned char *olddest
=dest
;
47 if (c
>= 'A' && c
<= 'Z') x
=c
-'A';
48 else if (c
>= 'a' && c
<= 'z') x
=c
-'a' + 26;
49 else if (c
>= '0' && c
<= '9') x
=c
-'0' + 52;
50 else if (c
== '+') x
=62;
51 else if (c
== '/') x
=63;
60 if (--destsize
<0) break;
62 *dest
++ = (char)((accum
>>nbits
)&0xff);
69 #endif // _BASE64ENCDEC_H_