| 137 | } |
| 138 | |
| 139 | bool Base64Encode(const char* in, int64_t in_len, int64_t out_max, char* out, |
| 140 | unsigned* out_len) { |
| 141 | if (UNLIKELY(in_len < 0 || in_len > std::numeric_limits<unsigned>::max() || |
| 142 | out_max < 0 || out_max > std::numeric_limits<unsigned>::max())) { |
| 143 | return false; |
| 144 | } |
| 145 | const int encode_result = sasl_encode64(in, static_cast<unsigned>(in_len), out, |
| 146 | static_cast<unsigned>(out_max), out_len); |
| 147 | if (UNLIKELY(encode_result != SASL_OK || *out_len != out_max - 1)) return false; |
| 148 | return true; |
| 149 | } |
| 150 | |
| 151 | void Base64Encode(const char* in, int64_t in_len, stringstream* out) { |
| 152 | if (in_len == 0) { |