12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * Author: Patrick-Christopher Mattulat
- * Company: Lynar Studios
- * E-Mail: webmaster@lynarstudios.com
- * Created: 2022-01-03
- * Changed: 2022-05-20
- *
- * */
- #ifndef LS_STD_BASE64_HPP
- #define LS_STD_BASE64_HPP
- #include <ls_std/core/interface/IEncoding.hpp>
- #include <bitset>
- #include <vector>
- #include <unordered_map>
- namespace ls
- {
- namespace std
- {
- namespace encoding
- {
- class Base64 : public ls::std::core::interface_type::IEncoding
- {
- public:
- Base64() = default;
- ~Base64() = default;
- // implementation
- ::std::string encode(const ::std::string &_sequence) override;
- ::std::string decode(const ::std::string &_sequence) override;
- private:
- static ::std::string _applyEndingRule(::std::string _encodedString, size_t _sequenceSize);
- static ::std::string _decodeByteQuadruple(const ::std::string &_quadruple);
- static ::std::string _encodeByteTriple(const ::std::string &_byteTriple);
- static uint32_t _extractBitSequence(uint32_t _bitMask, uint32_t _bitStorage);
- static uint32_t _generateBitMask(uint32_t _maskValue, uint8_t _shiftValue);
- static ::std::unordered_map<char, uint8_t> _getDecodingMap();
- static ::std::unordered_map<uint8_t, char> _getEncodingMap();
- static ::std::string _getNextByteQuadruple(const ::std::string &_sequence, size_t _index);
- static ::std::string _getNextByteTriple(const ::std::string &_sequence, size_t _index);
- static void _mergeBitSequence(uint32_t &_bitStorage, const uint32_t &_bitMask);
- static uint32_t _toDecodingBitStorage(const ::std::string &_quadruple);
- static uint32_t _toEncodingBitStorage(const ::std::string &_triple);
- };
- }
- }
- }
- #endif
|