Luna/libluna/include/luna/SHA.h
apio db2f91b1fb
All checks were successful
Build and test / build (push) Successful in 2m26s
libluna+apps: Add a SHA256 hash implementation
2024-07-20 15:50:59 +02:00

41 lines
735 B
C++

/**
* @file SHA.h
* @author apio (cloudapio.eu)
* @brief SHA256 algorithm implementation.
*
* @copyright Copyright (c) 2024, the Luna authors.
*
*/
#pragma once
#include <luna/Buffer.h>
#include <luna/String.h>
/**
* @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<void> append(const u8* data, usize size);
/**
* @brief Calculate the final hash.
*
* @return Buffer The calculated hash.
*/
Result<Buffer> digest();
static Result<String> hash_to_string(const Buffer& buffer);
private:
Buffer m_message;
};