+
+#ifdef SHA1_SUM
+/*
+ * Reads a single ASCII file and prints the HEX sha1 sum.
+ */
+#include <stdio.h>
+int main(int argc, char *argv[])
+{
+ FILE *fd;
+ SHA1Context ctx;
+ char buf[5000];
+ char signature[25];
+
+ if (argc < 1) {
+ printf("Must have filename\n");
+ exit(1);
+ }
+ fd = fopen(argv[1], "rb");
+ if (!fd) {
+ berrno be;
+ printf("Could not open %s: ERR=%s\n", argv[1], be.bstrerror(errno));
+ exit(1);
+ }
+ SHA1Init(&ctx);
+ while (fgets(buf, sizeof(buf), fd)) {
+ SHA1Update(&ctx, (unsigned char *)buf, strlen(buf));
+ }
+ SHA1Final(&ctx, (unsigned char *)signature);
+ for (int i=0; i < 20; i++) {
+ printf("%02x", signature[i]& 0xFF);
+ }
+ printf(" %s\n", argv[1]);
+}
+#endif