summaryrefslogtreecommitdiff
path: root/test-sha1.c
blob: 2efc315ee3cfa4cfc7c5d191d9b673d727cc40ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "cache.h"

int main(int ac, char **av)
{
	SHA_CTX ctx;
	unsigned char sha1[20];

	SHA1_Init(&ctx);

	while (1) {
		ssize_t sz;
		char buffer[8192];
		sz = xread(0, buffer, sizeof(buffer));
		if (sz == 0)
			break;
		if (sz < 0)
			die("test-sha1: %s", strerror(errno));
		SHA1_Update(&ctx, buffer, sz);
	}
	SHA1_Final(sha1, &ctx);
	puts(sha1_to_hex(sha1));
	exit(0);
}