return HashWithMode(file_name, MsgDigest, 'b');
}
-int HashStringMode(char Msg[],char MsgDigest[])
+void HashStringMode(char Msg[],char MsgDigest[])
{
unsigned char output[hashbitlen/4];
Hash(hashbitlen,(unsigned char*) Msg,sizeof(Msg),output);
printHexMsg(output,hashbitlen/4,MsgDigest);
- return 1;
+}
+
+void HashStdin(char MsgDigest[], int tag)
+{
+ char stri[100];
+ char longstring[1000];
+ longstring[0] = 0;
+ while(fgets(stri,100,stdin))
+ strcat(longstring, stri);
+ HashStringMode(longstring, MsgDigest);
+ if (tag) {
+ printf("skein%d_v%s (-) = %s\n", hashbitlen, skeinVersion, MsgDigest);
+ } else {
+ printf("%s *-\n", MsgDigest);
+ }
}
int isProper(char MsgDigest[])
}
}
else if(errorFound != 1)
- { // read stdin for strings
- char stri[100];
- char longstring[1000];
- longstring[0] = 0;
- while((fgets(stri,100,stdin))!=NULL)
- {
- strcat(longstring,stri);
- }
- HashStringMode(longstring,MsgDigest);
- if(tag == 1)
- {
- printf("skein%d_v%s (-) = %s\n",hashbitlen,skeinVersion,MsgDigest);
- }
- else
- {
- printf("%s *-\n",MsgDigest);
- }
+ {
+ HashStdin(MsgDigest, tag);
}
}
}
}
else if(errorFound != 1)
- { // read stdin for strings
- char stri[100];
- char longstring[1000];
- longstring[0] = 0;
- while((fgets(stri,100,stdin))!=NULL)
- {
- strcat(longstring,stri);
- }
- HashStringMode(longstring,MsgDigest);
- if(tag == 1)
- {
- printf("skein%d_v%s (-) = %s\n",hashbitlen,skeinVersion,MsgDigest);
- }
- else
- {
- printf("%s -\n",MsgDigest);
- }
+ {
+ HashStdin(MsgDigest, tag);
}
}
}
}
else if(errorFound != 1)
- { // hasing strings read from stdin
- char stri[100];
- char longstring[1000]; /* TODO!!! Fix buffer overflow!!! */
- longstring[0] = 0;
- while((fgets(stri,100,stdin))!=NULL)
- {
- strcat(longstring,stri);
- }
- HashStringMode(longstring,MsgDigest);
- if(tag == 1)
- {
- printf("skein%d_v%s (-) = %s\n",hashbitlen,skeinVersion,MsgDigest);
- }
- else
- {
- printf("%s -\n",MsgDigest);
- }
+ {
+ HashStdin(MsgDigest, tag);
}
}
else if(check == 1)
}
}
- if ((errorFound != 1) && (argc == 1 || (hashString == 1 && number_files == 0)))
- {
- char stri[100];
- char longstring[1000];
- longstring[0] = 0;
- while((fgets(stri,100,stdin))!=NULL)
- {
- strcat(longstring,stri);
- }
- HashStringMode(longstring,MsgDigest);
- printf("%s -\n",MsgDigest);
- }
+ if (!errorFound && (argc == 1 || (hashString == 1 && !number_files)))
+ HashStdin(MsgDigest, 0);
return 1;
}