65 #include <lifev/core/util/EncoderBase64.hpp> 72 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 73 "abcdefghijklmnopqrstuvwxyz" 79 return (isalnum (c) || (c ==
'+') || (c ==
'/') );
82 std::string base64_encode (
unsigned char const* bytes_to_encode,
UInt in_len)
87 unsigned char char_array_3[3];
88 unsigned char char_array_4[4];
92 char_array_3[i++] = * (bytes_to_encode++);
95 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
96 char_array_4[1] = ( (char_array_3[0] & 0x03) << 4) + ( (char_array_3[1] & 0xf0) >> 4);
97 char_array_4[2] = ( (char_array_3[1] & 0x0f) << 2) + ( (char_array_3[2] & 0xc0) >> 6);
98 char_array_4[3] = char_array_3[2] & 0x3f;
100 for (i = 0; (i < 4) ; i++)
102 ret += base64_chars[char_array_4[i]];
110 for (j = i; j < 3; j++)
112 char_array_3[j] =
'\0';
115 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
116 char_array_4[1] = ( (char_array_3[0] & 0x03) << 4) + ( (char_array_3[1] & 0xf0) >> 4);
117 char_array_4[2] = ( (char_array_3[1] & 0x0f) << 2) + ( (char_array_3[2] & 0xc0) >> 6);
118 char_array_4[3] = char_array_3[2] & 0x3f;
120 for (j = 0; (j < i + 1); j++)
122 ret += base64_chars[char_array_4[j]];
136 std::string base64_decode (std::string
const& encoded_string)
138 int in_len = encoded_string.size();
142 unsigned char char_array_4[4], char_array_3[3];
145 while (in_len-- && ( encoded_string[in_] !=
'=') && is_base64 (encoded_string[in_]) )
147 char_array_4[i++] = encoded_string[in_];
151 for (i = 0; i < 4; i++)
153 char_array_4[i] = base64_chars.find (char_array_4[i]);
156 char_array_3[0] = (char_array_4[0] << 2) + ( (char_array_4[1] & 0x30) >> 4);
157 char_array_3[1] = ( (char_array_4[1] & 0xf) << 4) + ( (char_array_4[2] & 0x3c) >> 2);
158 char_array_3[2] = ( (char_array_4[2] & 0x3) << 6) + char_array_4[3];
160 for (i = 0; (i < 3); i++)
162 ret += char_array_3[i];
170 for (j = i; j < 4; j++)
175 for (j = 0; j < 4; j++)
177 char_array_4[j] = base64_chars.find (char_array_4[j]);
180 char_array_3[0] = (char_array_4[0] << 2) + ( (char_array_4[1] & 0x30) >> 4);
181 char_array_3[1] = ( (char_array_4[1] & 0xf) << 4) + ( (char_array_4[2] & 0x3c) >> 2);
182 char_array_3[2] = ( (char_array_4[2] & 0x3) << 6) + char_array_4[3];
184 for (j = 0; (j < i - 1); j++)
186 ret += char_array_3[j];
void updateInverseJacobian(const UInt &iQuadPt)
static bool is_base64(unsigned char c)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
static const std::string base64_chars