RTU_ALL_AI/release/inc/myMd5.h

42 lines
932 B
C

/**
* @file myMd5.h
* @brief MD5 message digest (RFC 1321)
* @details Computes 128-bit hash. Supports streaming update.
*/
#ifndef _MY_MD5_H_
#define _MY_MD5_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief MD5 context (state + count + pending buffer)
*/
typedef struct
{
uint32_t state[4]; /* A, B, C, D */
uint32_t count[2]; /* bit count low/high */
unsigned char buf[64]; /* pending bytes */
} stru_md5_ctx;
/** Initialize context with magic constants */
void md5_start(stru_md5_ctx *ctx);
/** Feed data, callable multiple times */
void md5_update(stru_md5_ctx *ctx, const unsigned char *data, int len);
/** Finalize, get 16-byte digest */
void md5_final(stru_md5_ctx *ctx, unsigned char result[16]);
/** One-shot: compute MD5 of string, output 32-char hex (uppercase) */
void md5_string(const char *input, char output[33]);
#ifdef __cplusplus
}
#endif
#endif