QPMS
Electromagnetic multiple scattering library and toolkit.
Loading...
Searching...
No Matches
sha256.h
Go to the documentation of this file.
1
8#ifndef QPMS_SHA256_H
9#define QPMS_SHA256_H
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <stddef.h>
15#include <stdint.h>
16
18typedef struct {
19 uint32_t h[8];
20 uint64_t nbytes;
21 uint8_t block[64];
22 size_t blocklen;
24
27
29void qpms_sha256_update(qpms_sha256_t *ctx, const void *data, size_t len);
30
32
33void qpms_sha256_final(qpms_sha256_t *ctx, uint8_t out[32]);
34
36
38void qpms_sha256_hex(char hex[65], const void *data, size_t len);
39
41
44int qpms_sha256_file_hex(char hex[65], const char *path);
45
46#ifdef __cplusplus
47}
48#endif
49#endif // QPMS_SHA256_H
void qpms_sha256_update(qpms_sha256_t *ctx, const void *data, size_t len)
Feeds len bytes into the hash.
Definition sha256.c:72
void qpms_sha256_init(qpms_sha256_t *ctx)
Initialises the hash state.
Definition sha256.c:63
void qpms_sha256_final(qpms_sha256_t *ctx, uint8_t out[32])
Finishes the hash and writes the 32-byte digest to out.
Definition sha256.c:98
int qpms_sha256_file_hex(char hex[65], const char *path)
One-shot SHA-256 of a whole file.
Definition sha256.c:133
void qpms_sha256_hex(char hex[65], const void *data, size_t len)
One-shot SHA-256 of a buffer.
Definition sha256.c:119
Incremental SHA-256 state.
Definition sha256.h:18
size_t blocklen
Bytes currently buffered in block.
Definition sha256.h:22
uint64_t nbytes
Total number of bytes processed.
Definition sha256.h:20