----------------------------------------------------------- New Message on MumbaiUserGroup
----------------------------------------------------------- From: mahesh_m Message 1 in Discussion 20 November 2005 How Do I... _________________________________________________________________ How Do I Generate and compare a hash value? It is easy to generate and compare hash values using the cryptographic resources contained in the System.Security.Cryptography namespace. Because all hash functions take input of type Byte[], it might be necessary to convert the source into a byte array before it is hashed. To generate a hash value, create an instance of a hash algorithm and call ComputeHash() on it. The following code creates an instance of the MD5 hash algorithm and calls ComputeHash() on it. The hash function returns a byte array containing the hash value of the byte array Input VB.NET Dim HashVal As Byte() = New MD5CryptoServiceProvider().ComputeHash(Input) C# Byte[] HashVal = (new MD5CryptoServiceProvider()).ComputeHash(Input); Note that ComputeHash() is the final operation performed on an instance of a hash object. If another hash value needs to be generated, a new instance of a hash algorithm must be created. System.Security.Cryptography contains implementations of MD5, SHA1, SHA256, SHA384, and SHA512. The following code computes a SHA1 hash value VB.NET Dim HashVal As Byte() = New SHA1CryptoServiceProvider().ComputeHash(Input) C# Byte[] HashVal = (new SHA1CryptoServiceProvider()).ComputeHash(Input); _________________________________________________________________ You can also post your questions which you think are of the form "How Do I...?" to [EMAIL PROTECTED] . I will try to answer them in this section. -- -- Thank You, Regards, m_mahesh Mahesh Mitkari INETA Volunteer Asst. Manager (Pune .net User group) Manager (PUG Student) 09890555485 ([EMAIL PROTECTED]) http://mmahesh.blogspot.com _________________________________________________________________ Note: The information Published under this section is ONLY FOR INFORMATIVE PURPOSE of the User Group Members. The most of the part of this section is collected from the Microsoft .Net Framework SDK 2.0, Microsoft website, Resource kit published by the Microsoft and MSDN Library. It may be published here as some part or full article as it is originally published by Microsoft and may be copyrighted or won by the respective owner or Microsoft. We cannot guarantee the accuracy of any information. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights. ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
