🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
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.

27 lines
605 B

  1. /**
  2. * \file mischelper.c
  3. *
  4. * Source file with miscellaneous helper functions.
  5. */
  6. #include <SDL_test.h>
  7. void
  8. SDLVisualTest_HashString(char* str, char hash[33])
  9. {
  10. SDLTest_Md5Context md5c;
  11. int i;
  12. if(!str)
  13. {
  14. SDLTest_LogError("str argument cannot be NULL");
  15. return;
  16. }
  17. SDLTest_Md5Init(&md5c);
  18. SDLTest_Md5Update(&md5c, (unsigned char*)str, SDL_strlen(str));
  19. SDLTest_Md5Final(&md5c);
  20. /* convert the md5 hash to an array of hexadecimal digits */
  21. for(i = 0; i < 16; i++)
  22. SDL_snprintf(hash + 2 * i, 33 - 2 * i, "%02x", (int)md5c.digest[i]);
  23. }