Move stuff from main to separate PrintStringHash routine
authorJason Self <j@jxself.org>
Mon, 28 Sep 2015 00:53:50 +0000 (17:53 -0700)
committerJason Self <j@jxself.org>
Mon, 28 Sep 2015 00:53:50 +0000 (17:53 -0700)
skein_cli.c

index e95f4b60844f9e90db443def874a87c9e453d678..d761fd79b652d4f93bc8cd093d38661ff1700526 100644 (file)
@@ -366,6 +366,15 @@ int VerifyHashesFromFile(FILE *fp, int status, int warn, int quiet)
        return (NotProper || NoMatch) ? -1 : 1;
 }
 
+void PrintStringHash(const char *s)
+{
+       unsigned char output[hashbitlen/4];
+       char digest[hashbitlen/4 + 1];
+       Hash(hashbitlen, s, strlen(s), output);
+       hash2hexstr(output, digest);
+       printf("%s -%s\n", digest, s);
+}
+
 void print_version(void)
 {
        printf("skein%dsum 1.0\n", hashbitlen);
@@ -481,13 +490,8 @@ int main(int argc, char** argv)
                        WARN("command line should contain strings for hashing\n");
                        TRYHELP_GOODBYE();
                }
-               for( ; n < argc; n++) {
-                       unsigned char output[hashbitlen/4];
-                       char digest[hashbitlen/4 + 1];
-                       Hash(hashbitlen, argv[n], strlen(argv[n]), output);
-                       hash2hexstr(output, digest);
-                       printf("%s -%s\n", digest, argv[n]);
-               }
+               while (n < argc)
+                       PrintStringHash(argv[n++]);
                return 0;
        }