This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View file

@ -0,0 +1,44 @@
#ifndef STAR_SHA_256_HPP
#define STAR_SHA_256_HPP
#include "StarString.hpp"
#include "StarByteArray.hpp"
namespace Star {
typedef struct sha_state_struct {
uint32_t state[8], length, curlen;
uint8_t buf[64];
} sha_state;
class Sha256Hasher {
public:
Sha256Hasher();
void push(char const* data, size_t length);
void push(String const& data);
void push(ByteArray const& data);
// Produces 32 bytes
void compute(char* hashDestination);
ByteArray compute();
private:
bool m_finished;
sha_state m_state;
};
// Sha256 must, obviously, have 32 bytes available in the destination.
void sha256(char const* source, size_t length, char* hashDestination);
ByteArray sha256(char const* source, size_t length);
void sha256(ByteArray const& in, ByteArray& out);
void sha256(String const& in, ByteArray& out);
ByteArray sha256(ByteArray const& in);
ByteArray sha256(String const& in);
}
#endif