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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
George GeorgePosted Apr 11, 2008, 5:53 AM
Cool, Alan !
regards,
George
AlanPosted Apr 11, 2008, 5:45 AM
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 GeorgePosted Apr 11, 2008, 5:29 AM
Thanks Bechir Bejaoui,
Question answered.
regards,
George
Bechir BejaouiPosted Apr 11, 2008, 4:54 AM
int hash = oString.GetHashCode();
MessageBox.Show("OString hash code is : " + hash.ToString());