Hashing Data Programmatically                                                        
•        Once you have created a specific hash algorithm type, you will need to transform your message (such
as a block of character data) into a byte array.
•        This can be achieved using the System.Text.Encoding type.
•        The Encoding.GetBytes() method will transform an array of character data or a System.String type into
the required byte array.

•        The following example illustrates how a textual message can be used as input to the MD5 hash
algorithm:
•        The following is code example is in C#.
•        The only major difference in VB code would be the declaration of the local variables using the Dim
keyword.
static void Main(string[] args)
{
// Here is the message to hash.
string myMsg = "Hey there.";

// Create a new hash algorithm type using Create().
HashAlgorithm hashAlg = HashAlgorithm.Create("MD5");

// Now encode the string into a byte array.
byte[] myMsgAsByteArray = Encoding.Default.GetBytes(myMsg);

// Now hash it.
byte[] myHashCode = hashAlg.ComputeHash(myMsgAsByteArray);

Console.WriteLine("Hash code of: {0}", myMsg);

// Format as hex with a padding of 2 (just to make it look nice ;-)
foreach(byte x in myHashCode)
Console.Write("{0:X2} ", x);
Console.WriteLine();
}
Hashing Data Programmatically
Table of Contents
Copyright (c) 2008.  Intertech, Inc. All Rights Reserved.  This information is to be used exclusively as an
online learning aid.  Any attempts to copy, reproduce, or use for training is strictly prohibited.
Courseware
Training Resources
Tutorials