' specify the path to a file and this routine will calculate your hash
Public Function MD5CalcFile(ByVal filepath As String) As String
' open file (as read-only)
Using reader As New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
Using md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
' hash contents of this stream
Dim hash() As Byte = md5.ComputeHash(reader)
' return formatted hash
Return ByteArrayToString(hash)
End Using
End Using
End Function
' utility function to convert a byte array into a hex string
Private Function ByteArrayToString(ByVal arrInput() As Byte) As String
Dim sb As New System.Text.StringBuilder(arrInput.Length * 2)
For i As Integer = 0 To arrInput.Length - 1
sb.Append(arrInput(i).ToString("X2"))
Next
Return sb.ToString().ToLower
End Function
if MD5CalcFile(filepath) = "md5 of the check file" = true then
'logon script
else
msgbox("Key not found, please contact creator")
end if