File syn_sha256.h¶
FileList > src > syntropic > util > syn_sha256.h
Go to the source code of this file
SHA-256 cryptographic hash — pure C99, zero dependencies. More...
#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_SHA256 SHA-256 hash context — caller-owned. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_sha256_final (SYN_SHA256 * ctx, uint8_t hash) Finalize the hash and produce the 32-byte digest. |
| void | syn_sha256_init (SYN_SHA256 * ctx) Initialize a SHA-256 context. |
| void | syn_sha256_update (SYN_SHA256 * ctx, const void * data, size_t len) Feed data into the hash. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | syn_sha256 (const void * data, size_t len, uint8_t hash) Compute SHA-256 of a complete buffer (one-shot convenience). |
Macros¶
| Type | Name |
|---|---|
| define | SYN_SHA256_BLOCK_SIZE 64SHA-256 block size in bytes. |
| define | SYN_SHA256_DIGEST_SIZE 32SHA-256 digest size in bytes. |
Detailed Description¶
Follows the same streaming pattern as syn_crc.h: init → update (repeated) → final
The context struct is caller-owned (~112 bytes on 32-bit targets). No heap allocation, no floating point, no external libraries.
** **
// One-shot:
uint8_t hash[32];
syn_sha256("abc", 3, hash);
// Streaming:
SYN_SHA256 ctx;
syn_sha256_init(&ctx);
syn_sha256_update(&ctx, chunk1, len1);
syn_sha256_update(&ctx, chunk2, len2);
syn_sha256_final(&ctx, hash);
Public Functions Documentation¶
function syn_sha256_final¶
Finalize the hash and produce the 32-byte digest.
After calling this, the context must be re-initialized before reuse.
Parameters:
ctxSHA-256 context.hashOutput buffer (must be at least 32 bytes).
function syn_sha256_init¶
Initialize a SHA-256 context.
Parameters:
ctxContext to initialize.
function syn_sha256_update¶
Feed data into the hash.
Can be called repeatedly with arbitrary chunk sizes.
Parameters:
ctxSHA-256 context.dataData to hash.lenLength in bytes.
Public Static Functions Documentation¶
function syn_sha256¶
Compute SHA-256 of a complete buffer (one-shot convenience).
Parameters:
dataData to hash.lenLength in bytes.hashOutput buffer (must be at least 32 bytes).
Macro Definition Documentation¶
define SYN_SHA256_BLOCK_SIZE¶
SHA-256 block size in bytes.
define SYN_SHA256_DIGEST_SIZE¶
SHA-256 digest size in bytes.
The documentation for this class was generated from the following file src/syntropic/util/syn_sha256.h