md5.h 1.2 KB

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