2014-01-07 03:23:44 +01:00
|
|
|
#ifndef __HASHFUNCTIONS_H__
|
|
|
|
#define __HASHFUNCTIONS_H__
|
|
|
|
|
2014-01-14 08:48:20 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-03-03 09:45:03 +01:00
|
|
|
#include <gtest/gtest.h>
|
2014-01-17 09:39:42 +01:00
|
|
|
#include "../sha1.h"
|
2014-01-07 03:23:44 +01:00
|
|
|
|
2014-03-03 09:45:03 +01:00
|
|
|
static void CompareHash(const unsigned char* digest, const char* hashStr) {
|
2014-01-07 03:23:44 +01:00
|
|
|
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';
|
2014-03-03 09:45:03 +01:00
|
|
|
EXPECT_STREQ(hashStr, hashStrCmp);
|
2014-01-07 03:23:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //__HASHFUNCTIONS_H__
|