What is the correct way to use the MD5Fingerprint() command as I get repeated results with different code, including a still repeated but varied alternative:
First, if you pass a string to a function, in reality the pointer to that string is passed.
That is, because strings are always handled through their pointers, no matter if it is a literal string or a string variable.
So when writing "MD5FingerPrint("Bob",..." you actually call the function
MD5Fingerprint with the location of the bytes 'B','o','b', followed by a 0 byte.
So technically, this is exactly the same as you did with the AllocateMemory line.
The only difference is that the one data (literal string) is statically stored at the end of the source code,
and the allocated buffer is *somewhere* in memory.
But in both ways you call the function with a pointer to a buffer with the exact same data.
That's why the results are the same.
As for the diference between the '1st' and '2nd' lines. The difference is quite simple.
"Len("Bob")" obviously returns 3. So with '1st', you are calculating the
fingerprint of the bytes 'B','o' and 'b'.
With the '2nd' way, you include one more byte, which is the terminating 0
of the string. So this is a different buffer, of course the resulting fingerprint if different.
Thanks for your help, but you haven't quite cleared up my problem. Is it correct to create a MD5Fingerprint of "Bob" or a MD5Fingerprint of "Bob" with the null terminator byte?
~I see one problem with your reasoning: the fact is thats not a chicken~
Sorry.
I see me neither Freak understood your question.
I think it must be done without the 0 if you want to checksum just "Bob", but if you want to checksum "Bob"+Chr(0), then it must be done including the null terminator byte.
It just depends on what you want to do
Last edited by Psychophanta on Wed Feb 23, 2005 5:49 pm, edited 1 time in total.