libhasha 2.2.2
|
Header file for I/O operations related to hashing. More...
#include "./internal/feature.h"
#include "./internal/hadefs.h"
#include "./internal/internal.h"
#include "internal/types.h"
Go to the source code of this file.
Macros | |
#define | HA_IO_ENDLINE_LF "\n" |
#define | HA_IO_ENDLINE_CRLF "\r\n" |
#define | HA_IO_ENDLINE HA_IO_ENDLINE_LF |
#define | ha_hash2str_bound(len) |
#define | ha_str2hash_bound(len) |
#define | ha_strhash_bound(len) |
Functions | |
HA_PUBFUN size_t | ha_fputhash (FILE *stream, ha_cdigest_t digest, size_t digestlen, const char *end) |
Writes the hash digest to the specified file stream. | |
HA_PUBFUN size_t | ha_puthash (ha_cdigest_t digest, size_t digestlen, const char *end) |
Outputs the hash digest to standard output. | |
HA_PUBFUN size_t | ha_hash2str (char *dst, ha_cdigest_t src, size_t len) |
Converts a hash digest to a hexadecimal string representation. | |
HA_PUBFUN size_t | ha_str2hash (ha_digest_t dst, const char *src, size_t len) |
Converts a hexadecimal string representation to a hash digest. | |
HA_PUBFUN size_t | ha_strhash (char *dst, ha_cdigest_t src, size_t len) |
HA_PUBFUN int | ha_cmphash (ha_cdigest_t lhs, ha_cdigest_t rhs, size_t digestlen) |
Compares two hash digests byte by byte. | |
HA_PUBFUN int | ha_cmphashstr (ha_cdigest_t lhs, const char *rhs, size_t digestlen) |
Compares a hash digest with a hexadecimal string representation. |
Header file for I/O operations related to hashing.
This file defines the API for handling I/O operations with hash digests, including writing digests to a file stream and outputting digests to the standard output.
Definition in file io.h.
#define HA_IO_ENDLINE HA_IO_ENDLINE_LF |
#define ha_strhash_bound | ( | len | ) |
HA_PUBFUN int ha_cmphash | ( | ha_cdigest_t | lhs, |
ha_cdigest_t | rhs, | ||
size_t | digestlen ) |
Compares two hash digests byte by byte.
This function compares two hash digests (byte arrays) of the same length. It returns 0 if the digests are equal, and a non-zero value if they are different.
lhs | The first hash digest to compare. |
rhs | The second hash digest to compare. |
digestlen | The length of the hash digests. |
HA_PUBFUN int ha_cmphashstr | ( | ha_cdigest_t | lhs, |
const char * | rhs, | ||
size_t | digestlen ) |
Compares a hash digest with a hexadecimal string representation.
This function compares a hash digest (byte array) with a hexadecimal string. It first converts the hash digest to its string representation and then compares the resulting string with the given hexadecimal string.
lhs | The hash digest to compare. |
rhs | The hexadecimal string to compare with. |
digestlen | The length of the hash digest. |
HA_PUBFUN size_t ha_fputhash | ( | FILE * | stream, |
ha_cdigest_t | digest, | ||
size_t | digestlen, | ||
const char * | end ) |
Writes the hash digest to the specified file stream.
This function writes the given hash digest to the provided file stream. It is useful for storing hash digests in files for later verification or comparison.
stream | The file stream to write the digest to. |
digest | The hash digest to write. |
digestlen | The length of the hash digest. |
end | It will be printed at the end, unless of course it is NULL |
HA_PUBFUN size_t ha_hash2str | ( | char * | dst, |
ha_cdigest_t | src, | ||
size_t | len ) |
Converts a hash digest to a hexadecimal string representation.
This function converts the given hash digest (byte array) into a hexadecimal string and stores it in the provided dst buffer. Each byte of the digest is converted to a two-character hexadecimal representation.
dst | The destination buffer to store the hexadecimal string. |
src | The hash digest (byte array) to convert. |
len | The length of the hash digest. |
HA_PUBFUN size_t ha_puthash | ( | ha_cdigest_t | digest, |
size_t | digestlen, | ||
const char * | end ) |
Outputs the hash digest to standard output.
This function outputs the given hash digest to the standard output, typically for printing or displaying the result of a hash computation to the user.
digest | The hash digest to output. |
digestlen | The length of the hash digest. |
end | It will be printed at the end, unless of course it is NULL |
HA_PUBFUN size_t ha_str2hash | ( | ha_digest_t | dst, |
const char * | src, | ||
size_t | len ) |
Converts a hexadecimal string representation to a hash digest.
This function converts the provided hexadecimal string into its corresponding binary hash digest. Each byte in the resulting digest is represented by two hexadecimal characters in the input string. The conversion stops after processing len bytes (i.e. 2 * len characters from the input string), or earlier if an invalid hexadecimal digit is encountered.
dst | The destination buffer where the binary hash digest will be stored. |
src | The source hexadecimal string to be converted. It should contain at least 2 * len valid hexadecimal characters. |
len | The expected number of bytes in the binary hash digest. |
HA_PUBFUN size_t ha_strhash | ( | char * | dst, |
ha_cdigest_t | src, | ||
size_t | len ) |