| 60 | } |
| 61 | |
| 62 | bool Base64::WebSafeDecode(const StringPiece& input, std::string* output) |
| 63 | { |
| 64 | std::string temp; |
| 65 | temp.resize(modp_b64r_decode_len(input.size())); |
| 66 | |
| 67 | // does not null terminate result since result is binary data! |
| 68 | int input_size = static_cast<int>(input.size()); |
| 69 | int output_size = modp_b64r_decode(&(temp[0]), input.data(), input_size); |
| 70 | if (output_size < 0) |
| 71 | return false; |
| 72 | |
| 73 | temp.resize(output_size); |
| 74 | output->swap(temp); |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | } // namespace toft |