initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
typedef struct {
|
||||
uint64_t length;
|
||||
uint32_t state[8];
|
||||
uint32_t curlen;
|
||||
uint8_t buf[64];
|
||||
} Sha256Context;
|
||||
|
||||
typedef std::array<uint8_t, 32> Sha256Digest;
|
||||
|
||||
// Initialises a SHA256 Context. Use this to initialise/reset a context.
|
||||
void sha256Initialise(Sha256Context* Context);
|
||||
|
||||
// Adds data to the SHA256 context. This will process the data and update the
|
||||
// internal state of the context. Keep on calling this function until all the
|
||||
// data has been added. Then call Sha256Finalise to calculate the hash.
|
||||
void sha256Update(Sha256Context* Context, void const* Buffer, uint32_t BufferSize);
|
||||
|
||||
// Performs the final calculation of the hash and returns the digest (32 byte
|
||||
// buffer containing 256bit hash). After calling this, Sha256Initialised must
|
||||
// be used to reuse the context.
|
||||
void sha256Finalise(Sha256Context* Context, Sha256Digest& Digest);
|
||||
|
||||
// Combines Sha256Initialise, Sha256Update, and Sha256Finalise into one
|
||||
// function. Calculates the SHA256 hash of the buffer.
|
||||
void sha256Calculate(void const* Buffer, uint32_t BufferSize, Sha256Digest& Digest);
|
||||
|
||||
// Converts a SHA256_HASH to a human-readable string.
|
||||
std::string sha256ToString(const Sha256Digest& Digest);
|
||||
Reference in New Issue
Block a user