MFMD5.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef _MF_MD5_H_
  2. #define _MF_MD5_H_
  3. //#pragma warning(disable:4786)
  4. #include <string>
  5. #include <fstream>
  6. extern "C"
  7. {
  8. bool _Md5_CheckFile(const char * srcFile, unsigned char* dst);
  9. }
  10. using namespace std;
  11. namespace mf
  12. {
  13. /*!
  14. * Manage MD5.
  15. */
  16. class CMD5
  17. {
  18. private:
  19. #define uint8 unsigned char
  20. #define uint32 unsigned int
  21. struct md5_context
  22. {
  23. uint32 total[2];
  24. uint32 state[4];
  25. uint8 buffer[64];
  26. };
  27. void md5_starts( struct md5_context *ctx );
  28. void md5_process( struct md5_context *ctx, uint8 data[64] );
  29. void md5_update( struct md5_context *ctx, uint8 *input, uint32 length );
  30. void md5_finish( struct md5_context *ctx, uint8 digest[16] );
  31. public:
  32. //! construct a CMD5 from any buffer
  33. void GenerateMD5(unsigned char* buffer,int bufferlen);
  34. void GenerateMD5(ifstream &in);
  35. void GenerateMD5(const char * src_file);
  36. //! construct a CMD5
  37. CMD5();
  38. //! construct a md5src from char *
  39. CMD5(const char * md5src);
  40. //! construct a CMD5 from a 16 bytes md5
  41. CMD5(unsigned long* md5src);
  42. //! add a other md5
  43. CMD5 operator +(CMD5 adder);
  44. //! just if equal
  45. bool operator ==(CMD5 cmper);
  46. //! give the value from equer
  47. // void operator =(CMD5 equer);
  48. //! to a string
  49. string ToString();
  50. unsigned long m_data[4];
  51. };
  52. };
  53. #endif /* md5.h */