Click here to Skip to main content
15,890,506 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: References in Class Library Pin
Gideon Engelberth28-Jan-10 2:51
Gideon Engelberth28-Jan-10 2:51 
GeneralRe: References in Class Library Pin
Jay Royall28-Jan-10 4:49
Jay Royall28-Jan-10 4:49 
QuestionDelete record using ADODC in vb6 Pin
offroaderdan27-Jan-10 23:48
offroaderdan27-Jan-10 23:48 
AnswerRe: Delete record using ADODC in vb6 Pin
Estys28-Jan-10 0:20
Estys28-Jan-10 0:20 
GeneralRe: Delete record using ADODC in vb6 Pin
offroaderdan28-Jan-10 0:50
offroaderdan28-Jan-10 0:50 
GeneralRe: Delete record using ADODC in vb6 Pin
Estys28-Jan-10 1:24
Estys28-Jan-10 1:24 
QuestionMDX Change array to list Pin
led12327-Jan-10 3:44
led12327-Jan-10 3:44 
QuestionMD5 checksum problem Pin
Gagan.2027-Jan-10 2:18
Gagan.2027-Jan-10 2:18 
Hi all.

I have two functions to generate MD5 checksum of a file. The problem is that when I am computing checksum of some files, then sometime both functions are generating same hashvalue for same file but for some files both functions are generating different values.

The functions I am using are below :

function 1

Public Function GetMD5(ByVal file As String) As String
        Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider
        Dim f As FileStream = New FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
        md5.ComputeHash(f)
        Dim hash As Byte() = md5.Hash
        f.Close()
        Dim buff As StringBuilder = New StringBuilder
        Dim hashByte As Byte
        For Each hashByte In hash
            buff.Append(String.Format("{0:X1}", hashByte))
        Next
        Return buff.ToString()
    End Function


function 2

Public function DoChecksum(ByVal file As String) as string

        Dim csp As New MD5CryptoServiceProvider()
        Try
            Dim stm As FileStream = New FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read, 8192)
            Dim hash As Byte() = csp.ComputeHash(stm)
            stm.Close()

            Dim computed As String = BitConverter.ToString(hash).Replace("-", "")
return computed
    End function


Tell me where is the problem. Is there any problem in writing code or anything else.

Also suggest me how could I verify that file is modified or not by MD5 checksum.

Thanks.

Gagan
AnswerRe: MD5 checksum problem Pin
Covean27-Jan-10 2:37
Covean27-Jan-10 2:37 
GeneralRe: MD5 checksum problem Pin
Gagan.2027-Jan-10 2:48
Gagan.2027-Jan-10 2:48 
GeneralRe: MD5 checksum problem Pin
DaveAuld27-Jan-10 3:06
professionalDaveAuld27-Jan-10 3:06 
GeneralRe: MD5 checksum problem Pin
Covean27-Jan-10 3:06
Covean27-Jan-10 3:06 
GeneralRe: MD5 checksum problem Pin
Gagan.2027-Jan-10 3:11
Gagan.2027-Jan-10 3:11 
GeneralRe: MD5 checksum problem Pin
DaveAuld27-Jan-10 3:25
professionalDaveAuld27-Jan-10 3:25 
GeneralRe: MD5 checksum problem Pin
Covean27-Jan-10 4:02
Covean27-Jan-10 4:02 
GeneralRe: MD5 checksum problem Pin
Gagan.2027-Jan-10 4:12
Gagan.2027-Jan-10 4:12 
GeneralRe: MD5 checksum problem Pin
Covean27-Jan-10 4:34
Covean27-Jan-10 4:34 
GeneralRe: MD5 checksum problem Pin
Luc Pattyn27-Jan-10 7:36
sitebuilderLuc Pattyn27-Jan-10 7:36 
QuestionDatagrid Pin
sohil masani26-Jan-10 19:54
sohil masani26-Jan-10 19:54 
AnswerRe: Datagrid [modified] Pin
Mr Oizo26-Jan-10 20:46
Mr Oizo26-Jan-10 20:46 
AnswerRe: Datagrid Pin
Paramu197326-Jan-10 20:46
Paramu197326-Jan-10 20:46 
QuestionRetrieve data from listview to textbox (VBA Access 2007) Pin
misCafe26-Jan-10 13:53
misCafe26-Jan-10 13:53 
AnswerRe: Retrieve data from listview to textbox (VBA Access 2007) Pin
Paramu197326-Jan-10 20:53
Paramu197326-Jan-10 20:53 
GeneralRe: Retrieve data from listview to textbox (VBA Access 2007) Pin
misCafe26-Jan-10 21:51
misCafe26-Jan-10 21:51 
GeneralRe: Retrieve data from listview to textbox (VBA Access 2007) Pin
Paramu197326-Jan-10 22:05
Paramu197326-Jan-10 22:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.