3 Imports System.Security.Cryptography
\r
5 Public Module TestUtils
\r
7 Public Function GenerateHash(ByVal SourceText As String) As String
\r
8 'Create an encoding object to ensure the encoding standard for the source text
\r
9 Dim Ue As New UnicodeEncoding()
\r
11 'Retrieve a byte array based on the source text
\r
12 Dim ByteSourceText() As Byte = Ue.GetBytes(SourceText)
\r
14 'Instantiate an MD5 Provider object
\r
15 Dim Md5 As New MD5CryptoServiceProvider()
\r
17 'Compute the hash value from the source
\r
18 Dim ByteHash() As Byte = Md5.ComputeHash(ByteSourceText)
\r
20 'And convert it to String format for return
\r
21 Return Convert.ToBase64String(ByteHash)
\r