]> git.ipfire.org Git - thirdparty/git.git/blame - test-sha1.c
Makefile: add framework to verify and bench sha1 implementations.
[thirdparty/git.git] / test-sha1.c
CommitLineData
b65bc21e
JH
1#include "cache.h"
2
3int main(int ac, char **av)
4{
5 SHA_CTX ctx;
6 unsigned char sha1[20];
7
8 SHA1_Init(&ctx);
9
10 while (1) {
11 ssize_t sz;
12 char buffer[8192];
13 sz = xread(0, buffer, sizeof(buffer));
14 if (sz == 0)
15 break;
16 if (sz < 0)
17 die("test-sha1: %s", strerror(errno));
18 SHA1_Update(&ctx, buffer, sz);
19 }
20 SHA1_Final(sha1, &ctx);
21 puts(sha1_to_hex(sha1));
22 exit(0);
23}
24