Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / sha-example.c
blobdcd889c73e88ab257d15324377e6ae47c1c26f6c
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include <nettle/sha1.h>
6 #define BUF_SIZE 1000
8 static void
9 display_hex(unsigned length, uint8_t *data)
11 unsigned i;
13 for (i = 0; i<length; i++)
14 printf("%02x ", data[i]);
16 printf("\n");
19 int
20 main(int argc, char **argv)
22 struct sha1_ctx ctx;
23 uint8_t buffer[BUF_SIZE];
24 uint8_t digest[SHA1_DIGEST_SIZE];
26 sha1_init(&ctx);
27 for (;;)
29 int done = fread(buffer, 1, sizeof(buffer), stdin);
30 sha1_update(&ctx, done, buffer);
31 if (done < sizeof(buffer))
32 break;
34 if (ferror(stdin))
35 return EXIT_FAILURE;
37 sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
39 display_hex(SHA1_DIGEST_SIZE, digest);
40 return EXIT_SUCCESS;