/reporting/crashsender/md5.h

http://crashrpt.googlecode.com/ · C Header · 96 lines · 25 code · 14 blank · 57 comment · 0 complexity · 8c1982ed1047949c419e23c09e841677 MD5 · raw file

  1. /*************************************************************************************
  2. This file is a part of CrashRpt library.
  3. Copyright (c) 2003-2013 The CrashRpt project authors. All Rights Reserved.
  4. Use of this source code is governed by a BSD-style license
  5. that can be found in the License.txt file in the root of the source
  6. tree. All contributing project authors may
  7. be found in the Authors.txt file in the root of the source tree.
  8. ***************************************************************************************/
  9. /*
  10. * This is the C++ implementation of the MD5 Message-Digest
  11. * Algorithm desrcipted in RFC 1321.
  12. * I translated the C code from this RFC to C++.
  13. * There is no warranty.
  14. *
  15. * Feb. 12. 2005
  16. * Benjamin Grüdelbach
  17. */
  18. /*
  19. * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  20. * rights reserved.
  21. *
  22. * License to copy and use this software is granted provided that it
  23. * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
  24. * Algorithm" in all material mentioning or referencing this software
  25. * or this function.
  26. *
  27. * License is also granted to make and use derivative works provided
  28. * that such works are identified as "derived from the RSA Data
  29. * Security, Inc. MD5 Message-Digest Algorithm" in all material
  30. * mentioning or referencing the derived work.
  31. *
  32. * RSA Data Security, Inc. makes no representations concerning either
  33. * the merchantability of this software or the suitability of this
  34. * software for any particular purpose. It is provided "as is"
  35. * without express or implied warranty of any kind.
  36. *
  37. * These notices must be retained in any copies of any part of this
  38. * documentation and/or software.
  39. */
  40. //----------------------------------------------------------------------
  41. //include protection
  42. #ifndef MD5_H
  43. #define MD5_H
  44. //----------------------------------------------------------------------
  45. //STL includes
  46. #include <string>
  47. //----------------------------------------------------------------------
  48. //typedefs
  49. typedef unsigned char *POINTER;
  50. /*
  51. * MD5 context.
  52. */
  53. typedef struct
  54. {
  55. unsigned long int state[4]; /* state (ABCD) */
  56. unsigned long int count[2]; /* number of bits, modulo 2^64 (lsb first) */
  57. unsigned char buffer[64]; /* input buffer */
  58. } MD5_CTX;
  59. /*
  60. * MD5 class
  61. */
  62. class MD5
  63. {
  64. private:
  65. void MD5Transform (unsigned long int state[4], unsigned char block[64]);
  66. void Encode (unsigned char*, unsigned long int*, unsigned int);
  67. void Decode (unsigned long int*, unsigned char*, unsigned int);
  68. void MD5_memcpy (POINTER, POINTER, unsigned int);
  69. void MD5_memset (POINTER, int, unsigned int);
  70. public:
  71. void MD5Init (MD5_CTX*);
  72. void MD5Update (MD5_CTX*, unsigned char*, unsigned int);
  73. void MD5Final (unsigned char [16], MD5_CTX*);
  74. MD5(){};
  75. };
  76. //----------------------------------------------------------------------
  77. //End of include protection
  78. #endif
  79. /*
  80. * EOF
  81. */