sizeof(sha1string)
is the same thing as sizeof(unsigned char*)
, i.e. the size of a data pointer. You want to pass the string's length there, use strlen
instead of sizeof
, otherwise you won't be hashing what you think you're hashing.
If tempString
isn't a null-terminated string but arbitrary data, you need to pass in the length of the data to checkHash
, there's no way in that case to tell the length from within that function.