return (NotProper || NoMatch) ? -1 : 1;
}
-int isProper(char MsgDigest[])
+int isProper(const char MsgDigest[])
{
- if ((strlen(MsgDigest) - hashbitlen/4) != 0)
+ int len = strlen(MsgDigest);
+ if (len != (hashbitlen / 4))
return 0;
int index = 0;
- char c = 0;
- for(index = 0; index < strlen(MsgDigest);index++)
+ for (index = 0; index < len; index++)
{
- c = MsgDigest[index];
- if(!(( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'F')))
- return 0;
+ char c = MsgDigest[index];
+ if (c >= '0' && c <= '9') continue;
+ if (c >= 'A' && c <= 'F') continue;
+ return 0;
}
return 1;