file_encryptor_decryptor.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include <string>
  2. #include <fstream>
  3. #include "colors.hpp"
  4. #ifndef _FILE_ENCRYPTOR_DECRYPTOR_HPP_
  5. #define _FILE_ENCRYPTOR_DECRYPTOR_HPP_
  6. namespace alex
  7. {
  8. /**
  9. * @class FileEncryptorDecryptor
  10. *
  11. * @brief Simple file encryptor and decryptor
  12. */
  13. class FileEncryptorDecryptor
  14. {
  15. public:
  16. FileEncryptorDecryptor() noexcept;
  17. FileEncryptorDecryptor(const std::string& target_filename) noexcept;
  18. FileEncryptorDecryptor(const FileEncryptorDecryptor&) = delete;
  19. FileEncryptorDecryptor& operator=(const FileEncryptorDecryptor&) = delete;
  20. ~FileEncryptorDecryptor() noexcept;
  21. inline void set_target_filename(const std::string& new_target_filename) noexcept
  22. { m_target_file_name = new_target_filename; }
  23. void encrypt(const uint64_t base_key, const uint32_t salt_key) noexcept;
  24. void decrypt(const uint64_t base_key, const uint32_t salt_key) noexcept;
  25. private:
  26. std::string m_target_file_name;
  27. std::fstream m_in_out_file_stream;
  28. };
  29. } // namespace alex
  30. #endif // _FILE_ENCRYPTOR_DECRYPTOR_HPP_