Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.2 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. History:
  6. --*/
  7. #include "precomp.h"
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <memory.h>
  11. #include "md5.h"
  12. #include "md5wbem.h"
  13. void MD5::Transform(
  14. IN LPVOID pInputValue,
  15. IN UINT uValueLength,
  16. OUT BYTE MD5Buffer[16]
  17. )
  18. {
  19. MD5_CTX Ctx;
  20. MD5Init(&Ctx);
  21. MD5Update(
  22. &Ctx,
  23. (unsigned char *) pInputValue,
  24. uValueLength
  25. );
  26. MD5Final(&Ctx);
  27. CopyMemory(MD5Buffer, Ctx.digest, 16);
  28. }
  29. void MD5::ContinueTransform(
  30. IN LPVOID pInputValue,
  31. IN UINT uValueLength,
  32. IN OUT BYTE MD5Buffer[16]
  33. )
  34. {
  35. MD5_CTX Ctx;
  36. MD5Init(&Ctx); // zeros buffer, and counts
  37. CopyMemory( Ctx.buf, MD5Buffer, 16 );
  38. MD5Update(
  39. &Ctx,
  40. (unsigned char *) pInputValue,
  41. uValueLength
  42. );
  43. MD5Final(&Ctx);
  44. CopyMemory(MD5Buffer, Ctx.digest, 16);
  45. }
  46. #ifdef TESTEXE
  47. void main()
  48. {
  49. char buf[128];
  50. printf("Enter a string to be digested:");
  51. gets(buf);
  52. BYTE MD5Digest[16];
  53. MD5::Transform(buf, strlen(buf), MD5Digest);
  54. for (int i = 0; i < 16; i++)
  55. printf("%02x", MD5Digest[i]);
  56. }
  57. #endif