base64.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // This file is part of BOINC.
  2. // http://boinc.berkeley.edu
  3. // Copyright (C) 2008 University of California
  4. //
  5. // BOINC is free software; you can redistribute it and/or modify it
  6. // under the terms of the GNU Lesser General Public License
  7. // as published by the Free Software Foundation,
  8. // either version 3 of the License, or (at your option) any later version.
  9. //
  10. // BOINC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. // See the GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with BOINC. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef BOINC_BASE64_H
  18. #define BOINC_BASE64_H
  19. #ifndef _WIN32
  20. #include <cstdio>
  21. #include <cstdlib>
  22. #include <string>
  23. #endif
  24. class InvalidBase64Exception
  25. {
  26. };
  27. std::string r_base64_encode(const char* from, size_t length);
  28. std::string r_base64_decode(const char* from, size_t length);
  29. inline std::string r_base64_encode(std::string const& from)
  30. {
  31. return r_base64_encode(from.c_str(), from.length());
  32. }
  33. inline std::string r_base64_decode(std::string const& from)
  34. {
  35. return r_base64_decode(from.c_str(), from.length());
  36. }
  37. #endif