From 3d3b000f9960b72a30b84a895a287cb5c5053e1b Mon Sep 17 00:00:00 2001 From: avinal <185067@nith.ac.in> Date: Sun, 21 Mar 2021 23:06:52 +0530 Subject: [PATCH] recast str to uint --- include/Encryptor.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 include/Encryptor.h diff --git a/include/Encryptor.h b/include/Encryptor.h new file mode 100644 index 0000000..4d6fe17 --- /dev/null +++ b/include/Encryptor.h @@ -0,0 +1,43 @@ +/** + * /mnt/z/my_git/RCRS-CSD-327/include/Encryptor.hpp + * @file Encryptor.hpp + * @author Avinal Kumar + * @since March 05, 2021 + * + * Encryptor class + */ + +#include +#include + +#if !defined(ENCRYPTOR_HPP) +#define ENCRYPTOR_HPP + +namespace krypto { +class Encryptor { + + uint32_t str_to_uint32(std::string const &block, int block_size) { + return *reinterpret_cast( + const_cast(block.substr(0, block_size).c_str())); + } + + std::string uint32_to_str(uint32_t digest, int const block_size) { + std::string data(""); + for (int i = 0; i < block_size; i++) { + data += (uint8_t)(digest >> i * 8); + } + return data; + } + +public: + Encryptor(); + ~Encryptor(); + uint64_t blowfish_encrypt(std::vector &input_buf, + std::string const &key, uint64_t in_size); + uint64_t blowfish_decrypt(std::vector const &input_buf, + std::string const &key, uint64_t in_size); +}; + +} // namespace krypto + +#endif // ENCRYPTOR_HPP