Started work on creating sha-1 caps hash

This commit is contained in:
James Booth
2013-01-20 17:16:45 +00:00
parent 4ecb69bfab
commit 64d81c7c4c
5 changed files with 102 additions and 2 deletions

View File

@@ -167,3 +167,29 @@ prof_getline(FILE *stream)
free(buf);
return s;
}
int
octet_compare(unsigned char *str1, unsigned char *str2)
{
if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") == 0)) {
return 0;
}
if ((strcmp((char *)str1, "") == 0) && (strcmp((char *)str2, "") != 0)) {
return -1;
}
if ((strcmp((char *)str1, "") != 0) && (strcmp((char *)str2, "") == 0)) {
return 1;
}
if (str1[0] == str2[0]) {
return octet_compare(&str1[1], &str2[1]);
}
if (str1[0] < str2[0]) {
return -1;
}
return 1;
}