Base64.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // base64 encoding and decoding with C++.
  3. // Version: 2.rc.03 (release candidate)
  4. //
  5. #ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
  6. #define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
  7. #include <string>
  8. #if __cplusplus >= 201703L
  9. #include <string_view>
  10. #endif // __cplusplus >= 201703L
  11. std::string base64_encode (std::string const& s, bool url = false);
  12. std::string base64_encode_pem (std::string const& s);
  13. std::string base64_encode_mime(std::string const& s);
  14. std::string base64_decode(std::string const& s, bool remove_linebreaks = false);
  15. std::string base64_encode(unsigned char const*, unsigned int len, bool url = false);
  16. #if __cplusplus >= 201703L
  17. //
  18. // Interface with std::string_view rather than const std::string&
  19. // Requires C++17
  20. // Provided by Yannic Bonenberger (https://github.com/Yannic)
  21. //
  22. std::string base64_encode (std::string_view s, bool url = false);
  23. std::string base64_encode_pem (std::string_view s);
  24. std::string base64_encode_mime(std::string_view s);
  25. std::string base64_decode(std::string_view s, bool remove_linebreaks = false);
  26. #endif // __cplusplus >= 201703L
  27. #endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */