CMS 3D CMS Logo

Functions
PixelBase64.h File Reference
#include <string>

Go to the source code of this file.

Functions

std::string base64_decode (std::string const &s)
 
std::string base64_encode (unsigned char const *, unsigned int len)
 

Function Documentation

◆ base64_decode()

std::string base64_decode ( std::string const &  s)

Definition at line 78 of file PixelBase64.cc.

78  {
79  int in_len = encoded_string.size();
80  int i = 0;
81  int j = 0;
82  int in_ = 0;
83  unsigned char char_array_4[4], char_array_3[3];
85 
86  while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
87  char_array_4[i++] = encoded_string[in_];
88  in_++;
89  if (i == 4) {
90  for (i = 0; i < 4; i++)
91  char_array_4[i] = base64_chars.find(char_array_4[i]);
92 
93  char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
94  char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
95  char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
96 
97  for (i = 0; (i < 3); i++)
98  ret += char_array_3[i];
99  i = 0;
100  }
101  }
102 
103  if (i) {
104  for (j = i; j < 4; j++)
105  char_array_4[j] = 0;
106 
107  for (j = 0; j < 4; j++)
108  char_array_4[j] = base64_chars.find(char_array_4[j]);
109 
110  char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
111  char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
112  char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
113 
114  for (j = 0; (j < i - 1); j++)
115  ret += char_array_3[j];
116  }
117 
118  return ret;
119 }

References base64_chars, mps_fire::i, is_base64(), dqmiolumiharvest::j, runTheMatrix::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ base64_encode()

std::string base64_encode ( unsigned char const *  ,
unsigned int  len 
)

Definition at line 38 of file PixelBase64.cc.

38  {
40  int i = 0;
41  int j = 0;
42  unsigned char char_array_3[3];
43  unsigned char char_array_4[4];
44 
45  while (in_len--) {
46  char_array_3[i++] = *(bytes_to_encode++);
47  if (i == 3) {
48  char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
49  char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
50  char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
51  char_array_4[3] = char_array_3[2] & 0x3f;
52 
53  for (i = 0; (i < 4); i++)
54  ret += base64_chars[char_array_4[i]];
55  i = 0;
56  }
57  }
58 
59  if (i) {
60  for (j = i; j < 3; j++)
61  char_array_3[j] = '\0';
62 
63  char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
64  char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
65  char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
66  char_array_4[3] = char_array_3[2] & 0x3f;
67 
68  for (j = 0; (j < i + 1); j++)
69  ret += base64_chars[char_array_4[j]];
70 
71  while ((i++ < 3))
72  ret += '=';
73  }
74 
75  return ret;
76 }

References base64_chars, mps_fire::i, dqmiolumiharvest::j, runTheMatrix::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by pos::PixelConfigBase::getComment(), pos::PixelROCMaskBits::writeXML(), and pos::PixelROCTrimBits::writeXML().

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
mps_fire.i
i
Definition: mps_fire.py:428
base64_chars
static const std::string base64_chars
Definition: PixelBase64.cc:31
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
is_base64
static bool is_base64(unsigned char c)
Definition: PixelBase64.cc:36
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66