openh264/test/utils/HashFunctions.h
Martin Storsjö 4f5fd952b6 Use the bundled sha1 implementation instead of relying on openssl
This simplifies running tests on platforms where OpenSSL isn't
commonly available.
2014-02-24 15:38:19 +02:00

18 lines
485 B
C

#ifndef __HASHFUNCTIONS_H__
#define __HASHFUNCTIONS_H__
#include <stdio.h>
#include <string.h>
#include "../sha1.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__