From: Jason Self Date: Mon, 28 Sep 2015 00:52:39 +0000 (-0700) Subject: Hashing cmdline strings added. X-Git-Url: https://jxself.org/git/?p=skeinsum.git;a=commitdiff_plain;h=a20d5ede618124ecba406fcca37cf92dbc202997 Hashing cmdline strings added. --- diff --git a/skein_cli.c b/skein_cli.c index 39e5ea0..e95f4b6 100644 --- a/skein_cli.c +++ b/skein_cli.c @@ -386,6 +386,7 @@ void print_usage(void) "-c, --check read skein sums from the FILEs and check them\n" "--tag create a BSD-style checksum\n" "-t, --text read in text mode (default)\n" + "-0 hash strings from command line\n" "\n" "The following three options are useful only when verifying checksums:\n" "--quiet don't print OK for each successfully verified file\n" @@ -448,10 +449,10 @@ int main(int argc, char** argv) /***************************************************************************************** ************************************* GETTING DATA *********************************** *****************************************************************************************/ - while ((opt = getopt_long (argc, argv, "hVbctw", long_options, NULL)) != -1) + while ((opt = getopt_long (argc, argv, "hVbctw0", long_options, NULL)) != -1) { switch (opt) { - case 0 : hashString = 1; break; + case '0' : hashString = 1; break; case 'b' : binary = 1; break; case 't' : binary = 0; break; case 'c' : check = 1; break; @@ -473,6 +474,23 @@ int main(int argc, char** argv) ************************************* PROCESSING DATA *********************************** *****************************************************************************************/ + if (hashString > 0) + { + int n = first_file; + if (n >= argc) { + 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]); + } + return 0; + } + if (check < 0) /* READ FILES, GENERATE CHECKSUMS AND PRINT TO STDOUT.. */ { if (quiet == 1 || warn == 1 || status == 1)