MD5Checksum.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #if !defined(AFX_MD5CHECKSUM_H__2BC7928E_4C15_11D3_B2EE_A4A60E20D2C3__INCLUDED_)
  2. #define AFX_MD5CHECKSUM_H__2BC7928E_4C15_11D3_B2EE_A4A60E20D2C3__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. /*****************************************************************************************
  7. *****************************************************************************************/
  8. class CMD5Checksum
  9. {
  10. public:
  11. static CString GetMD5OfString(CString strString);
  12. //interface functions for the RSA MD5 calculation
  13. static BYTE GetMD5(LPCTSTR sFilePath, CString &sMd5);
  14. protected:
  15. //constructor/destructor
  16. CMD5Checksum();
  17. virtual ~CMD5Checksum() {};
  18. //RSA MD5 implementation
  19. void Transform(BYTE Block[64]);
  20. void Update(BYTE* Input, ULONG nInputLen);
  21. CString Final();
  22. inline DWORD RotateLeft(DWORD x, int n);
  23. inline void FF( DWORD& A, DWORD B, DWORD C, DWORD D, DWORD X, DWORD S, DWORD T);
  24. inline void GG( DWORD& A, DWORD B, DWORD C, DWORD D, DWORD X, DWORD S, DWORD T);
  25. inline void HH( DWORD& A, DWORD B, DWORD C, DWORD D, DWORD X, DWORD S, DWORD T);
  26. inline void II( DWORD& A, DWORD B, DWORD C, DWORD D, DWORD X, DWORD S, DWORD T);
  27. //utility functions
  28. inline void DWordToByte(BYTE* Output, DWORD* Input, UINT nLength);
  29. inline void ByteToDWord(DWORD* Output, BYTE* Input, UINT nLength);
  30. private:
  31. BYTE m_lpszBuffer[64]; //input buffer
  32. ULONG m_nCount[2]; //number of bits, modulo 2^64 (lsb first)
  33. ULONG m_lMD5[4]; //MD5 checksum
  34. };
  35. #endif // !defined(AFX_MD5CHECKSUM_H__2BC7928E_4C15_11D3_B2EE_A4A60E20D2C3__INCLUDED_)