SHA256Print.c 1005 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*====================================================================*
  2. *
  3. * void SHA256Print (const uint8_t digest [], const char * string);
  4. *
  5. * HPAVKey.h
  6. *
  7. * print a digest in hexadecimal on stdout followed by string if
  8. * string is non-empty;
  9. *
  10. * Motley Tools by Charles Maier;
  11. * Copyright (c) 2001-2006 by Charles Maier Associates;
  12. * Licensed under the Internet Software Consortium License;
  13. *
  14. *--------------------------------------------------------------------*/
  15. #ifndef SHA256PRINT_SOURCE
  16. #define SHA256PRINT_SOURCE
  17. #include <stdio.h>
  18. #include "../key/SHA256.h"
  19. #include "../tools/number.h"
  20. void SHA256Print (const uint8_t digest [], const char * string)
  21. {
  22. unsigned length = SHA256_DIGEST_LENGTH;
  23. while (length--)
  24. {
  25. putc (DIGITS_HEX [(* digest >> 4) & 0x0F], stdout);
  26. putc (DIGITS_HEX [(* digest >> 0) & 0x0F], stdout);
  27. digest++;
  28. }
  29. if (string) for (putc (' ', stdout); *string; string++)
  30. {
  31. putc (*string, stdout);
  32. }
  33. printf ("\n");
  34. return;
  35. }
  36. #endif