From: Jason Self Date: Mon, 28 Sep 2015 00:53:50 +0000 (-0700) Subject: Move stuff from main to separate PrintStringHash routine X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=ed4a9a13de99577cefa1bb0d97398d36a64dbbb3;p=skeinsum.git Move stuff from main to separate PrintStringHash routine --- diff --git a/skein_cli.c b/skein_cli.c index e95f4b6..d761fd7 100644 --- a/skein_cli.c +++ b/skein_cli.c @@ -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; }