1 /* 2 * Copyright (C) 2020 Adrien Destugues <pulkomandy@pulkomandy.tk> 3 * 4 * Distributed under terms of the MIT license. 5 */ 6 7 #ifndef MD5_H 8 #define MD5_H 9 10 11 #include "md5.h" 12 13 14 class CMD5Helper 15 { 16 public: 17 18 CMD5Helper() 19 { 20 MD5_Init(&m_MD5Context); 21 m_nTotalBytes = 0; 22 } 23 24 inline void AddData(const void * pData, int nBytes) 25 { 26 MD5_Update(&m_MD5Context, (const unsigned char *) pData, nBytes); 27 m_nTotalBytes += nBytes; 28 } 29 30 void GetResult(unsigned char cResult[16]) 31 { 32 MD5_Final(cResult, &m_MD5Context); 33 } 34 35 protected: 36 37 MD5_CTX m_MD5Context; 38 int m_nTotalBytes; 39 }; 40 41 42 #endif /* !MD5_H */ 43