A simple VB.Net application to hash a string to a MD5 hash

I created the below console application in Visual Basic.Net Express 2008 to convert a given string to a MD5 hash, atteched is the complied EXE

Example usage:

C:\>MD5.exe String_To_Hash
5649c7d2b3cb75d98a5f4372d289d0b7

Module Module1
 
    Sub Main()
        Dim strToHash As String
        strToHash = Command$()
        Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
        Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
 
        bytesToHash = md5Obj.ComputeHash(bytesToHash)
 
        Dim strResult As String = ""
 
        For Each b As Byte In bytesToHash
            strResult += b.ToString("x2")
        Next
 
        Console.Write(strResult)
    End Sub
 
End Module

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.