I need to compare to strings (hashes consisting of numbers and letters). Now i'm thingking about performance... is it better, to use strcmp or md5 both strings and compare with a if-statement?<p>*edit: it's in a web-app using php
Is there an md5 function that returns a primitive type?<p>The ones I know of return structs or arrays, which you can't compare via == in C. (I assume you're using C since strcmp is used for C strings.)<p>If you already have the md5's precomputed, they're probably less data, so it would be faster in that case. If you include the time to compute md5, then strcmp is definitely faster. Intuitively, strcmp just needs to do one very fast pass over the strings, with just a single comparison per character; while md5 needs to do a lot more work just to compute its output.