Securing trough files

Posts 1–2 of 2 · Page 1 of 1
Securing trough files
On my program im using a login form.
But to secure it more i want it to read a file.

the file is a key
that key is a usb with a file on it.

I want it trough ftp that it reads the file on the usb and checks the file.

then when its the right file you can login.

I made something like that months ago but bad enough i lost all that files.

Thanks in advice
check the files MD5 hash, and if its the right one,
form1.show?



Code:
' 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
maybe something like....
Code:
if MD5CalcFile(filepath) = "md5 of the check file" = true then
'logon script
else
msgbox("Key not found, please contact creator")
end if
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?