2 * sha256sum.c -- simple SHA256 sum code (to get a binary output)
14 printf("usage: sha256sum [-hvb]\n");
17 int main(int argc, char *argv[])
19 struct sha256_ctx ctx;
20 unsigned char buf[64];
21 unsigned char hash[32];
25 while ((c = getopt(argc, argv, "?hvb")) > 0) {
31 printf("Version: 1.0.0\n");
43 sha256_init_ctx(&ctx);
45 c = fread(buf, 1, 64, stdin);
46 sha256_process_bytes(buf, c, &ctx);
48 sha256_finish_ctx(&ctx, hash);
51 fwrite(hash, 1, 32, stdout);
53 for (c = 0; (c < 32); c++)
54 printf("%02x", hash[c]);