Results 1 to 14 of 14

Thread: comparing files??[Resolved]

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    comparing files??[Resolved]

    I need a tool that compare files (very sensitive and maybe secured files)?I know this can be difficult to code in .NET !
    thanx for any help
    Last edited by Pirate; Feb 14th, 2003 at 03:56 PM.

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    maybe comparing the md5 digest will be a good way

  3. #3

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I would never code this!! .all what I need is a tool ??

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Lunatic3
    maybe comparing the md5 digest will be a good way
    What are you talking about here ?

  5. #5
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Well MD5 computes the message digest of a file or string. If two files generate a same MD5 digest then it has a very high probability that they are the same.

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    sounds easy but how can I start with this ?any idea or example .
    thanx

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I just know the concept and never tried the cryptography classes of .NET. I will give it a try.

  8. #8

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It's frustrating Class .I couldn't do anything .

  9. #9
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    See if this helps you

    VB Code:
    1. Dim md5test As New MD5CryptoServiceProvider()
    2.         Dim enc As New System.Text.ASCIIEncoding()
    3.         Dim cfile() As Byte
    4.         Dim compdigest As String
    5.         Dim FS As New FileStream("C:\test1.txt", FileMode.Open)
    6.         Dim sr As StreamReader = New StreamReader(FS)
    7.         cfile = enc.GetBytes(sr.ReadToEnd)
    8.         compdigest = enc.GetString(md5test.ComputeHash(cfile))
    9.         TextBox1.Text = compdigest
    10.         sr.Close()
    11.         FS.Close()
    12.         cfile = Nothing
    13.  
    14.         FS = New FileStream("C:\test2.txt", FileMode.Open)
    15.         sr = New StreamReader(FS)
    16.         cfile = enc.GetBytes(sr.ReadToEnd)
    17.         compdigest = enc.GetString(md5test.ComputeHash(cfile))
    18.         TextBox2.Text = compdigest
    19.         sr.Close()
    20.         FS.Close()
    21.         cfile = Nothing
    22.         If TextBox1.Text = TextBox2.Text Then
    23.             MessageBox.Show("Files are identical")
    24.         Else
    25.             MessageBox.Show("Files are different")
    26.         End If

  10. #10

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It works but I didn't compare those protected files yet ! just txt files.
    Thanx Lunatic3 .

  11. #11
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I have tested this on binary files and works fine. You dont even have to use a binaryreader to read those files. Ofcourse before going through this process you may first check for the files sizes and if they differ then they are different and if not then compare them this way.

  12. #12

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Good Idea ! but Can this tool compare Dlls ?(which is all the fuss over)???

  13. #13
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Even binary files like dll's when treated as text are bunch of ascii characters though not human readable. I tried ti and it works great with dlls. To test it, make two copies of one dll and try it. Then open one in a Hex editor and chnge only a byte and see the result.

  14. #14

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    I've tested it on some dlls and passed the test.
    Thanx dude!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width