Crc64.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  3. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 CRC64_EXPORTS
  4. // 符号编译的。在使用此 DLL 的
  5. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  6. // CRC64_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  7. // 符号视为是被导出的。
  8. #ifndef CRC64_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "Crc64X64D.lib")
  12. #else
  13. #pragma comment(lib, "Crc64X64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "Crc64D.lib")
  18. #else
  19. #pragma comment(lib, "Crc64.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #ifdef CRC64_EXPORTS
  24. #define CRC64_API __declspec(dllexport)
  25. #define CRC64_C_API extern "C" __declspec(dllexport)
  26. #else
  27. #define CRC64_API __declspec(dllimport)
  28. #define CRC64_C_API extern "C" __declspec(dllimport)
  29. #endif
  30. // 此类是从 Crc64.dll 导出的
  31. class CCrc64 {
  32. public:
  33. CCrc64(void);
  34. // TODO: 在此添加您的方法。
  35. };
  36. class CCrc32 {
  37. public:
  38. CCrc32(void);
  39. // TODO: 在此添加您的方法。
  40. };
  41. CRC64_C_API UINT64 GetCrc64(const char *pSrc, DWORD size);
  42. CRC64_API int GetCrc32(const char *pSrc, size_t size);
  43. CRC64_API unsigned short CRC16(const unsigned char* pDataIn, size_t iLenIn);
  44. /* PROTOTYPES should be set to one if and only if the compiler supports
  45. function argument prototyping.
  46. The following makes PROTOTYPES default to 0 if it has not already
  47. been defined with C compiler flags.
  48. */
  49. #ifndef PROTOTYPES
  50. #define PROTOTYPES 0
  51. #endif
  52. /* POINTER defines a generic pointer type */
  53. typedef unsigned char *POINTER;
  54. /* UINT2 defines a two byte word */
  55. typedef unsigned short int UINT2;
  56. /* UINT4 defines a four byte word */
  57. typedef unsigned long int UINT4;
  58. /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
  59. If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
  60. returns an empty list.
  61. */
  62. #if PROTOTYPES
  63. #define PROTO_LIST(list) list
  64. #else
  65. #define PROTO_LIST(list) ()
  66. #endif
  67. /* MD5 context. */
  68. typedef struct _MD5_CTX{
  69. UINT4 state[4]; /* state (ABCD) */
  70. UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
  71. unsigned char buffer[64];/* input buffer */
  72. } MD5_CTX;
  73. CRC64_C_API void MD5Init(MD5_CTX *);
  74. CRC64_C_API void MD5Update(MD5_CTX *, unsigned char *, unsigned int);
  75. CRC64_C_API void MD5Final(unsigned char[16], MD5_CTX *);
  76. /* extended function */
  77. CRC64_C_API int MDFile(char *filename, char *digest);
  78. CRC64_C_API void MDPrint(unsigned char digest[16]);
  79. CRC64_C_API void MDString(const char *str, unsigned char *digest);
  80. CRC64_C_API void MDData(char *data, int len, unsigned char *digest);