| 266 | } |
| 267 | |
| 268 | int Base64StringToBytesLength(const std::string& str) |
| 269 | { |
| 270 | if(str.size() < 7 || (str.size()-7) % 4 || str.substr(0,7) != "base64:") return -1; |
| 271 | |
| 272 | size_t c = ((str.size() - 7) / 4) * 3; |
| 273 | if(str[str.size()-1] == '=') { --c; |
| 274 | if(str[str.size()-2] == '=') --c; } |
| 275 | return c; |
| 276 | } |
| 277 | |
| 278 | ///parses a string in the same format as BytesToString |
| 279 | ///returns true if success. |