I want to compare two sha1 hashes for equality. What could be the most efficient way to do this? Currently, I am trying using memcmp. Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well, since you already know at compile-time how large the blocks are, you could do this:
But don’t take my advice blindly, you should measure any custom solution against the
memcmpsolution and only use it if it gives you a significant performance advantage. I wouldn’t even be surprised ifmemcmpwas still faster because it did something extremely clever and dirty.