mirror of
https://github.com/reactos/ccache.git
synced 2024-12-02 16:46:24 +00:00
Add hash_equal() function
This commit is contained in:
parent
f86dbeaf3c
commit
65c847fa22
1
ccache.h
1
ccache.h
@ -71,6 +71,7 @@ void hash_start(struct mdfour *md);
|
||||
void hash_buffer(struct mdfour *md, const void *s, size_t len);
|
||||
char *hash_result(struct mdfour *md);
|
||||
void hash_result_as_bytes(struct mdfour *md, unsigned char *out);
|
||||
int hash_equal(struct mdfour *md1, struct mdfour *md2);
|
||||
void hash_delimiter(struct mdfour *md, const char* type);
|
||||
void hash_string(struct mdfour *md, const char *s);
|
||||
void hash_int(struct mdfour *md, int x);
|
||||
|
9
hash.c
9
hash.c
@ -58,6 +58,15 @@ hash_result_as_bytes(struct mdfour *md, unsigned char *out)
|
||||
mdfour_result(md, out);
|
||||
}
|
||||
|
||||
int
|
||||
hash_equal(struct mdfour *md1, struct mdfour *md2)
|
||||
{
|
||||
unsigned char sum1[16], sum2[16];
|
||||
hash_result_as_bytes(md1, sum1);
|
||||
hash_result_as_bytes(md2, sum2);
|
||||
return memcmp(sum1, sum2, sizeof(sum1)) == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash some data that is unlikely to occur in the input. The idea is twofold:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user