openh264/test/utils/HashFunctions.h

16 lines
450 B
C
Raw Normal View History

2014-01-07 03:23:44 +01:00
#ifndef __HASHFUNCTIONS_H__
#define __HASHFUNCTIONS_H__
#include <openssl/sha.h>
static bool CompareHash(const unsigned char* digest, const char* hashStr) {
char hashStrCmp[SHA_DIGEST_LENGTH * 2 + 1];
for (int i = 0; i < SHA_DIGEST_LENGTH; ++i) {
sprintf(&hashStrCmp[i*2], "%.2x", digest[i]);
}
hashStrCmp[SHA_DIGEST_LENGTH * 2] = '\0';
return strncmp(hashStr, hashStrCmp, SHA_DIGEST_LENGTH * 2) == 0;
}
#endif //__HASHFUNCTIONS_H__