md5.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef MD5_H
  17. #define MD5_H
  18. #include "../common/types.h"
  19. class MD5 {
  20. public:
  21. struct MD5Context {
  22. uint32 hash[4];
  23. uint32 bytes[2];
  24. uint32 input[16];
  25. };
  26. static void Generate(const int8* buf, uint32 len, int8 digest[16]);
  27. static void Init(struct MD5Context *context);
  28. static void Update(struct MD5Context *context, const int8 *buf, uint32 len);
  29. static void Final(int8 digest[16], struct MD5Context *context);
  30. MD5();
  31. MD5(const uchar* buf, uint32 len);
  32. MD5(const char* buf, uint32 len);
  33. MD5(const int8 buf[16]);
  34. MD5(const char* iMD5String);
  35. void Generate(const char* iString);
  36. void Generate(const int8* buf, uint32 len);
  37. bool Set(const int8 buf[16]);
  38. bool Set(const char* iMD5String);
  39. bool operator== (const MD5& iMD5);
  40. bool operator== (const int8 iMD5[16]);
  41. bool operator== (const char* iMD5String);
  42. MD5& operator= (const MD5& iMD5);
  43. MD5* operator= (const MD5* iMD5);
  44. MD5* operator= (const int8* iMD5);
  45. operator const char* ();
  46. protected:
  47. int8 pMD5[16];
  48. private:
  49. static void byteSwap(uint32 *buf, uint32 words);
  50. static void Transform(uint32 hash[4], const int32 input[16]);
  51. char pMD5String[33];
  52. };
  53. #endif