![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | N_SHA256 |
| a SHA-256 in progress: plain data, copyable to fork a hash More... | |
Macros | |
| #define | N_SHA256_HEX_LEN 65 |
| size of its lowercase hex form, terminator included | |
| #define | N_SHA256_LEN 32 |
| size in bytes of a SHA-256 digest | |
Functions | |
| void | n_sha256 (const void *data, size_t len, unsigned char out[32]) |
| hash one buffer | |
| int | n_sha256_file (const char *path, unsigned char out[32]) |
| hash a file, read in pieces | |
| void | n_sha256_final (N_SHA256 *ctx, unsigned char out[32]) |
| finish: the digest, the state left spent | |
| void | n_sha256_hex (const unsigned char digest[32], char out[65]) |
| a digest as lowercase hex | |
| void | n_sha256_init (N_SHA256 *ctx) |
| start a hash | |
| void | n_sha256_update (N_SHA256 *ctx, const void *data, size_t len) |
| feed bytes | |
| struct N_SHA256 |
a SHA-256 in progress: plain data, copyable to fork a hash
Definition at line 57 of file n_sha256.h.
| Data Fields | ||
|---|---|---|
| unsigned char | block[64] | the block being filled |
| uint64_t | length | bytes hashed so far |
| uint32_t | state[8] | the eight working words |
| size_t | used | how much of it is filled |
| #define N_SHA256_HEX_LEN 65 |
size of its lowercase hex form, terminator included
Definition at line 54 of file n_sha256.h.
Referenced by hex_is(), and n_sha256_hex().
| #define N_SHA256_LEN 32 |
size in bytes of a SHA-256 digest
Definition at line 52 of file n_sha256.h.
Referenced by hex_is(), main(), n_sha256(), n_sha256_file(), n_sha256_final(), and n_sha256_hex().
| void n_sha256 | ( | const void * | data, |
| size_t | len, | ||
| unsigned char | out[32] ) |
hash one buffer
| data | the bytes, may be NULL when len is 0 |
| len | how many |
| out | receives N_SHA256_LEN bytes |
Definition at line 158 of file n_sha256.c.
References n_sha256_final(), n_sha256_init(), N_SHA256_LEN, and n_sha256_update().
Referenced by hex_is(), and main().
| int n_sha256_file | ( | const char * | path, |
| unsigned char | out[32] ) |
hash a file, read in pieces
| path | the file |
| out | receives N_SHA256_LEN bytes |
Definition at line 166 of file n_sha256.c.
References n_sha256_final(), n_sha256_init(), N_SHA256_LEN, and n_sha256_update().
Referenced by main().
| void n_sha256_final | ( | N_SHA256 * | ctx, |
| unsigned char | out[32] ) |
finish: the digest, the state left spent
| ctx | the hash |
| out | receives N_SHA256_LEN bytes |
Definition at line 132 of file n_sha256.c.
References _sha256_block(), N_SHA256::block, N_SHA256::length, N_SHA256_LEN, N_SHA256::state, and N_SHA256::used.
Referenced by main(), n_sha256(), and n_sha256_file().
| void n_sha256_hex | ( | const unsigned char | digest[32], |
| char | out[65] ) |
a digest as lowercase hex
| digest | N_SHA256_LEN bytes |
| out | receives N_SHA256_HEX_LEN characters, terminator included |
Definition at line 195 of file n_sha256.c.
References N_SHA256_HEX_LEN, and N_SHA256_LEN.
Referenced by hex_is().
| void n_sha256_init | ( | N_SHA256 * | ctx | ) |
start a hash
| ctx | the state to set up |
Definition at line 91 of file n_sha256.c.
References N_SHA256::length, N_SHA256::state, and N_SHA256::used.
Referenced by main(), n_sha256(), and n_sha256_file().
| void n_sha256_update | ( | N_SHA256 * | ctx, |
| const void * | data, | ||
| size_t | len ) |
feed bytes
| ctx | the hash |
| data | the bytes, may be NULL when len is 0 |
| len | how many |
Definition at line 103 of file n_sha256.c.
References _sha256_block(), N_SHA256::block, N_SHA256::length, N_SHA256::state, and N_SHA256::used.
Referenced by main(), n_sha256(), and n_sha256_file().