Base64.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2022-01-03
  6. * Changed: 2022-01-03
  7. *
  8. * */
  9. #ifndef LS_STD_BASE64_HPP
  10. #define LS_STD_BASE64_HPP
  11. #include <ls_std/encoding/IEncoding.hpp>
  12. #include <vector>
  13. namespace ls_std
  14. {
  15. class Base64 : public ls_std::IEncoding
  16. {
  17. public:
  18. Base64() = default;
  19. ~Base64() = default;
  20. std::string encode(const std::string &_sequence) override;
  21. std::string decode(const std::string &_sequence) override;
  22. private:
  23. const std::vector<char> table
  24. {
  25. 'A','B','C','D','E','F','G','H',
  26. 'I','J','K','L','M','N','O','P',
  27. 'Q','R','S','T','U','V','W','X',
  28. 'Y','Z','a','b','c','d','e','f',
  29. 'g','h','i','j','k','l','m','n',
  30. 'o','p','q','r','s','t','u','v',
  31. 'w','x','y','z','0','1','2','3',
  32. '4','5','6','7','8','9','+','/'
  33. };
  34. static std::string _getSubSequence(const std::string& _sequence, size_t index);
  35. };
  36. }
  37. #endif