31static void ToB64low(
const char *in,
char *out,
int mod)
33 static char b64ref[64] = {
34 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
35 'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
36 'U',
'V',
'W',
'X',
'Y',
'Z',
37 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
38 'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
39 'u',
'v',
'w',
'x',
'y',
'z',
40 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
45 *out++ = b64ref[ (
int)(0x3F & (in[0] >> 2)) ];
46 *out++ = b64ref[ 0x3F & ((0x30 & (in[0] << 4)) | (0x0F & (in[1] >> 4))) ];
47 *out++ = b64ref[ 0x3F & ((0x3C & (in[1] << 2)) | (0x03 & (in[2] >> 6))) ];
48 *out++ = b64ref[ 0x3F & in[2] ];
49 }
else if (mod == 1) {
50 *out++ = b64ref[ 0x3F & (in[0] >> 2) ];
51 *out++ = b64ref[ 0x3F & (0x30 & (in[0] << 4)) ];
54 }
else if (mod == 2) {
55 *out++ = b64ref[ 0x3F & (in[0] >> 2) ];
56 *out++ = b64ref[ 0x3F & ((0x30 & (in[0] << 4)) | (0x0F & (in[1] >> 4))) ];
57 *out++ = b64ref[ 0x3F & (0x3C & (in[1] << 2)) ];
69 static int b64inv[256] = {
70 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
71 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
72 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
73 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,
74 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
75 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
76 -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
77 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
78 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
79 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
80 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
81 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
82 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
83 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
84 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
85 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
93 out.
Append((
char)(0xFC & (b64inv[i0] << 2)) | (0x03 & (b64inv[i1] >> 4)));
94 out.
Append((
char)(0xF0 & (b64inv[i1] << 4)) | (0x0F & (b64inv[i2] >> 2)));
95 out.
Append((
char)(0xC0 & (b64inv[i2] << 6)) | (0x3F & b64inv[i3]));
96 }
else if (in[2] ==
'=') {
97 out.
Append((
char)(0xFC & (b64inv[i0] << 2)) | (0x03 & (b64inv[i1] >> 4)));
99 out.
Append((
char)(0xFC & (b64inv[i0] << 2)) | (0x03 & (b64inv[i1] >> 4)));
100 out.
Append((
char)(0xF0 & (b64inv[i1] << 4)) | (0x0F & (b64inv[i2] >> 2)));
120 for (
int i = 0; i <
len; i += 3) {
136 for (
int i = 0; i <
len; i += 4)
static void FromB64low(const char *in, TString &out)
Base64 decoding of 4 bytes from in.
static void ToB64low(const char *in, char *out, int mod)
Base64 encoding of 3 bytes from in.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
This code implements the Base64 encoding and decoding.
static TString Decode(const char *data)
Decode a base64 string date into a generic TString.
static TString Encode(const char *data)
Transform data into a null terminated base64 string.
TString & Append(const char *cs)