Code

Makefile: add framework to verify and bench sha1 implementations.
[git.git] / test-sha1.c
1 #include "cache.h"
3 int main(int ac, char **av)
4 {
5         SHA_CTX ctx;
6         unsigned char sha1[20];
8         SHA1_Init(&ctx);
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 }