visualtest/src/mischelper.c
author Ozkan Sezer
Thu, 21 Nov 2019 11:50:50 +0300
changeset 13267 a8e016c00f2e
parent 7924 fcb86d323770
permissions -rw-r--r--
ran gendynapi.pl after newly added SDL_string.c functions.
     1 /**
     2  * \file mischelper.c 
     3  *
     4  * Source file with miscellaneous helper functions.
     5  */
     6 
     7 #include <SDL_test.h>
     8 
     9 void
    10 SDLVisualTest_HashString(char* str, char hash[33])
    11 {
    12     SDLTest_Md5Context md5c;
    13     int i;
    14 
    15     if(!str)
    16     {
    17         SDLTest_LogError("str argument cannot be NULL");
    18         return;
    19     }
    20 
    21     SDLTest_Md5Init(&md5c);
    22     SDLTest_Md5Update(&md5c, (unsigned char*)str, SDL_strlen(str));
    23     SDLTest_Md5Final(&md5c);
    24 
    25     /* convert the md5 hash to an array of hexadecimal digits */
    26     for(i = 0; i < 16; i++)
    27         SDL_snprintf(hash + 2 * i, 33 - 2 * i, "%02x", (int)md5c.digest[i]);
    28 }