I found this code snippet here, but I just can’t figure out what the variables cSrt and result are!
for(int i = 0; i<1000000; i++){
CC_MD5(cStr, strlen(cStr), result);
sprintf(cStr, "%02x%02x", result[0], result[1]);
}
The compiler is telling me that they are char and unsigned char, but when I try to run it, it gives me an EXC_BAD_ACCESS at the sprintf-line.
Have you got any idea what I can do to make this snippet work? Thanks.
cStrandresultshould be arrays of (unsigned) chars, or pointers to (unsigned) char buffers.For example
Note that
cStrmay beconst, since it is only read, butresultshould be non-constant buffer, becauseCC_MD5writes the result there.Edit:
Actually, in this case,
cStrcannot be const, as you write to it in thesprintfline, but as far as you only use it inCC_MD5it should be OK.