/** * @file SHA.h * @author apio (cloudapio.eu) * @brief SHA256 algorithm implementation. * * @copyright Copyright (c) 2024, the Luna authors. * */ #pragma once #include #include #include /** * @brief A class to calculate a SHA256 hash. * */ class SHA256 { public: /** * @brief Add data to the hash. * * @param data The data to add. * @param size The amount of bytes to add. */ Result append(const u8* data, usize size); class Digest { public: const Slice bytes() { return { m_bytes, 32 }; } Result to_string(); private: u8 m_bytes[32]; friend class SHA256; }; /** * @brief Calculate the final hash. * * @return Digest The calculated hash digest. */ Result digest(); private: Buffer m_message; };