md5ex1.h 783 B

12345678910111213141516171819202122232425262728
  1. #ifndef MD5_H_EX1
  2. #define MD5_H_EX1
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #define MD5_BLOCK_SIZE 64
  6. #define MD5_DIGEST_SIZE 16
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. typedef struct {
  11. uint32_t state[4];
  12. uint32_t count[2];
  13. uint8_t buffer[MD5_BLOCK_SIZE];
  14. } MD5_CTXEx1;
  15. // 基础MD5函数
  16. void MD5_InitEx1(MD5_CTXEx1 *ctx);
  17. void MD5_UpdateEx1(MD5_CTXEx1 *ctx, const uint8_t *input, size_t len);
  18. void MD5_FinalEx1(uint8_t digest[MD5_DIGEST_SIZE], MD5_CTXEx1 *ctx);
  19. // 便捷函数
  20. void md5_hexEx1(const char *input, char *output);
  21. void md5_bytesEx1(const uint8_t *input, size_t len, char *output);
  22. void md5_tripleEx1(const char *input, char *output);
  23. // 工具函数
  24. void bytes_to_hexEx1(const uint8_t *bytes, size_t len, char *hex_str);
  25. #ifdef __cplusplus
  26. }
  27. #endif
  28. #endif