4 #include <nettle/sha1.h>
9 display_hex(unsigned length
, uint8_t *data
)
13 for (i
= 0; i
<length
; i
++)
14 printf("%02x ", data
[i
]);
20 main(int argc
, char **argv
)
23 uint8_t buffer
[BUF_SIZE
];
24 uint8_t digest
[SHA1_DIGEST_SIZE
];
29 int done
= fread(buffer
, 1, sizeof(buffer
), stdin
);
30 sha1_update(&ctx
, done
, buffer
);
31 if (done
< sizeof(buffer
))
37 sha1_digest(&ctx
, SHA1_DIGEST_SIZE
, digest
);
39 display_hex(SHA1_DIGEST_SIZE
, digest
);