Crc64.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include <cstdint> // 添加标准整数类型支持
  3. #include <cstddef> // 添加 size_t 支持
  4. #ifdef CRC64_EXPORTS
  5. #define CRC64_API
  6. #define CRC64_C_API extern "C"
  7. #else
  8. #define CRC64_API
  9. #define CRC64_C_API extern "C"
  10. #endif
  11. // 定义跨平台类型别名
  12. using DWORD = unsigned long; // Linux 兼容的 DWORD 类型
  13. using UINT64 = uint64_t; // 标准 64 位无符号整数
  14. using UINT4 = uint32_t; // 标准 32 位无符号整数
  15. using UINT2 = uint16_t; // 标准 16 位无符号整数
  16. using POINTER = unsigned char*;
  17. // 此类是从 Crc64.dll 导出的
  18. class CCrc64 {
  19. public:
  20. CCrc64(void);
  21. // TODO: 在此添加您的方法。
  22. };
  23. class CCrc32 {
  24. public:
  25. CCrc32(void);
  26. // TODO: 在此添加您的方法。
  27. };
  28. CRC64_C_API UINT64 GetCrc64(const char *pSrc, DWORD size);
  29. CRC64_API int GetCrc32(const char *pSrc, size_t size);
  30. CRC64_API unsigned short CRC16(const unsigned char* pDataIn, size_t iLenIn);
  31. /* PROTOTYPES should be set to one if and only if the compiler supports
  32. function argument prototyping.
  33. The following makes PROTOTYPES default to 0 if it has not already
  34. been defined with C compiler flags.
  35. */
  36. #ifndef PROTOTYPES
  37. #define PROTOTYPES 0
  38. #endif
  39. /* POINTER defines a generic pointer type */
  40. //typedef unsigned char *POINTER;
  41. //
  42. ///* UINT2 defines a two byte word */
  43. //typedef unsigned short int UINT2;
  44. //
  45. ///* UINT4 defines a four byte word */
  46. //typedef unsigned long int UINT4;
  47. /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  48. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  49. returns an empty list.
  50. */
  51. #if PROTOTYPES
  52. #define PROTO_LIST(list) list
  53. #else
  54. #define PROTO_LIST(list) ()
  55. #endif
  56. /* MD5 context. */
  57. typedef struct _MD5_CTX{
  58. UINT4 state[4]; /* state (ABCD) */
  59. UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
  60. unsigned char buffer[64];/* input buffer */
  61. } MD5_CTX;
  62. CRC64_C_API void MD5Init(MD5_CTX *);
  63. CRC64_C_API void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
  64. CRC64_C_API void MD5Final(unsigned char[16], MD5_CTX *);
  65. /* extended function */
  66. CRC64_C_API int MDFile(char *filename, char *digest);
  67. CRC64_C_API void MDPrint(unsigned char digest[16]);
  68. CRC64_C_API void MDString(const char *str, unsigned char *digest);
  69. CRC64_C_API void MDData(char *data, int len, unsigned char *digest);