[Help] MD5 Updater

Posts 18 of 8 · Page 1 of 1
[Help] MD5 Updater
As the title says, I'm searching for an updater that uses md5 hashes. Meaning like if I have 20 different files on my ftp...it does compare the md5 hashes and updates if necessary...

Any suggestions <.<?

This is what I've found so far:

Code:
  Public Sub CheckSumAndRun(ByVal filename As String)
        Try
            f = New System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read, 8192)
        Catch ex As Exception
            MsgBox(ex.Message)
            Exit Sub
        End Try
        md5 = New System.Security.Cryptography.MD5CryptoServiceProvider
        md5.ComputeHash(f)
        Dim hash As Byte() = md5.Hash
        Dim buff As System.Text.StringBuilder = New System.Text.StringBuilder
        Dim hashByte As Byte
        For Each hashByte In hash
            buff.Append(String.Format("{0:X2}", hashByte))
        Next
        f.Close()
        If buff.ToString = main_md5 Then
            p = Diagnostics.Process.Start(main_name, MainStartParam)
            Me.Close()
        Else
            If My.Computer.FileSystem.FileExists(currdir & main_name) = True Then
                My.Computer.FileSystem.DeleteFile(currdir & main_name, FileIO.UIOption.OnlyErrorDialogs, FileIO.RecycleOption.DeletePermanently)
            End If
            wrong_main = True
            BackgroundWorker1.RunWorkerAsync()
        End If
    End Sub
Here's the function that calculates the MD5 hash of a file:

[php]Public Function MD5CalcFile(ByVal filepath As String) As String

Using reader As New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
Using md5 As New System.Security.Cryptography.MD5CryptoServiceProvi der

Dim hash() As Byte = md5.ComputeHash(reader)
Return ByteArrayToString(hash)

End Using
End Using

End Function

[/php]

Convert the array to hex string:
[php]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

[/php]

Finally call the MD5CalcFile function to get the hash. Loop through all files and calculate it.
That does not help me in getting a updater to work =D

/Haz idea.

But go ahead and help xD
Quote Originally Posted by Blubb1337 View Post
That does not help me in getting a updater to work =D
You don't know how to retrieve the files in a folder from FTP ? If you do, then this would be working !!
I don't know exactly, unfortunately, can you tell me? I've never done this before.
Quote Originally Posted by Blubb1337 View Post
I don't know exactly, unfortunately, can you tell me? I've never done this before.
Hmm...ok give me a minute to write MD5 Updater for u !!
Wow does everyone insist on using coded updates? I do , but I do it commercially... If your developing a release or practice code etc... Use VB's built in Update feature...

@Flamestabber , Maybe it's just me, but something familiar about you.... , in either case... no need to be so aggressive in your responses, if you want to help...then help... if not, and you feel you know the answer and you are 100% correct, then don't bother ..
Quote Originally Posted by NextGen1 View Post
Wow does everyone insist on using coded updates? I do , but I do it commercially... If your developing a release or practice code etc... Use VB's built in Update feature...

@Flamestabber , Maybe it's just me, but something familiar about you.... , in either case... no need to be so aggressive in your responses, if you want to help...then help... if not, and you feel you know the answer and you are 100% correct, then don't bother ..
Lol, its Flame Sabber.

Ya we have a heavenly connection lol...

I was not aggressive, just trying to help him out ASAP coz I wanted to complete my project I was writing...

Anywayz, I talked to him on MSN, and he don't want to login to FTP and still wants to compare hashes !!
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?