Hello everyone,
I am new to how to use C# to calculate hash value for a string. I want to check we normally use MD5CryptoServiceProvider.ComputeHash?
As described here?
http://support.microsoft.com/kb/307020/en-us
thanks in advance,
George
Hello everyone,
I am new to how to use C# to calculate hash value for a string. I want to check we normally use MD5CryptoServiceProvider.ComputeHash?
As described here?
http://support.microsoft.com/kb/307020/en-us
thanks in advance,
George
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Bechir BejaouiRank #144 · 15.9K reputationPosted Apr 11, 2008, 12:54 AM EDT
int hash = oString.GetHashCode();
MessageBox.Show("OString hash code is : " + hash.ToString());
George GeorgeRank #1,736 · 870 reputationPosted Apr 11, 2008, 1:29 AM EDT
Thanks Bechir Bejaoui,
Question answered.
regards,
George
AlanRank #669 · 3.6K reputationPosted Apr 11, 2008, 1:45 AM EDT
I thought I should just add that the choice of methods depends on the level of security you need i.e. the lower the chance of producing a collision, the more secure the hash is.
String.GetHashCode() only produces a hash which is 32 bits long and so is not very secure.
In practice most people use the MD5 method (the one you mentioned) which produces a 128 bit hash or SHA1 which produces a 160 bit hash though both have been compromised in recent years.
For bullet-proof security, .NET also supports the SHA256, SHA384 and SHA512 algorithms.
George GeorgeRank #1,736 · 870 reputationPosted Apr 11, 2008, 1:53 AM EDT
Cool, Alan !
regards,
George