projects
/
skeinsum.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move stuff from main to separate PrintStringHash routine
[skeinsum.git]
/
skein_cli.c
diff --git
a/skein_cli.c
b/skein_cli.c
index 39e5ea03b2018c12f43f5b05892ea28af5b14d71..d761fd79b652d4f93bc8cd093d38661ff1700526 100644
(file)
--- 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;
}
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);
void print_version(void)
{
printf("skein%dsum 1.0\n", hashbitlen);
@@
-386,6
+395,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"
"-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"
"\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
+458,10
@@
int main(int argc, char** argv)
/*****************************************************************************************
************************************* GETTING DATA ***********************************
*****************************************************************************************/
/*****************************************************************************************
************************************* GETTING DATA ***********************************
*****************************************************************************************/
- while ((opt = getopt_long (argc, argv, "hVbctw", long_options, NULL)) != -1)
+ while ((opt = getopt_long (argc, argv, "hVbctw
0
", long_options, NULL)) != -1)
{
switch (opt) {
{
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;
case 'b' : binary = 1; break;
case 't' : binary = 0; break;
case 'c' : check = 1; break;
@@
-473,6
+483,18
@@
int main(int argc, char** argv)
************************************* PROCESSING DATA ***********************************
*****************************************************************************************/
************************************* PROCESSING DATA ***********************************
*****************************************************************************************/
+ if (hashString > 0)
+ {
+ int n = first_file;
+ if (n >= argc) {
+ WARN("command line should contain strings for hashing\n");
+ TRYHELP_GOODBYE();
+ }
+ while (n < argc)
+ PrintStringHash(argv[n++]);
+ return 0;
+ }
+
if (check < 0) /* READ FILES, GENERATE CHECKSUMS AND PRINT TO STDOUT.. */
{
if (quiet == 1 || warn == 1 || status == 1)
if (check < 0) /* READ FILES, GENERATE CHECKSUMS AND PRINT TO STDOUT.. */
{
if (quiet == 1 || warn == 1 || status == 1)