md5.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef __MD5_H__
  2. #define __MD5_H__
  3. #pragma once
  4. #include "config.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #include <stdlib.h>
  9. #include <stdint.h>
  10. #define MD5_DIGESTSIZE 16
  11. typedef struct md5_ctx_t md5_ctx_t;
  12. /** MD5 context. */
  13. struct md5_ctx_t {
  14. /** state (ABCD) */
  15. uint32_t state[4];
  16. /** number of bits, modulo 2^64 (lsb first) */
  17. uint32_t count[2];
  18. /** input buffer */
  19. unsigned char buffer[64];
  20. };
  21. TOOLKIT_API int md5_init(md5_ctx_t *context);
  22. /**
  23. * MD5 block update operation. Continue an MD5 message-digest operation,
  24. * processing another message block, and updating the context.
  25. * @param context The MD5 content to update.
  26. * @param input next message block to update
  27. * @param inputLen The length of the next message block
  28. */
  29. TOOLKIT_API int md5_update(md5_ctx_t *context,const void *input,size_t inputLen);
  30. /**
  31. * MD5 finalization. Ends an MD5 message-digest operation, writing the
  32. * message digest and zeroing the context
  33. * @param digest The final MD5 digest
  34. * @param context The MD5 content we are finalizing.
  35. */
  36. TOOLKIT_API int md5_final(unsigned char digest[MD5_DIGESTSIZE],md5_ctx_t *context);
  37. /**
  38. * MD5 in one step
  39. * @param digest The final MD5 digest
  40. * @param input The message block to use
  41. * @param inputLen The length of the message block
  42. */
  43. TOOLKIT_API int md5(unsigned char digest[MD5_DIGESTSIZE],const void *input,size_t inputLen);
  44. #ifdef __cplusplus
  45. } // extern "C" {
  46. #endif
  47. #endif // __MD5_H__