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

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

Example usage:

C:\>SHA1.exe String_To_Hash
92aca6d2d5997cb8d0186935eeda35058c686688

Module Module1
 
    Sub Main()
        Dim strToHash As String
        strToHash = Command$()
 
        Dim sha1Obj As New Security.Cryptography.SHA1CryptoServiceProvider
        Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
 
        bytesToHash = sha1Obj.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.