Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is GetHashCode for a file unique?

Posted on 2006-07-09
4
Medium Priority
?
740 Views
Last Modified: 2012-05-05
I'm using the following example to get the hash code for a file.  Is this hash code unique or could there be instances of overlapping?  If it's the later (instance of overlapping) help me understand how it occurs or if it's a rarity.

        OpenFileDialog1.FileName = ""
        OpenFileDialog1.ShowDialog()

        If OpenFileDialog1.FileName = "" Then Exit Sub

        Dim File_Stream As New System.IO.StreamReader(OpenFileDialog1.FileName)
        Dim File_Hash As Integer = File_Stream.ReadToEnd().GetHashCode()

        RichTextBox1.Text = File_Hash

        File_Stream.Close()
        File_Stream = Nothing
0
Comment
Question by:IUFITS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 17069614
it is a rarity, but collisions can occur.  It only returns a 32-bit value, so there are only 4+ billion unique hash values.

http://msdn2.microsoft.com/en-us/library/system.string.gethashcode.aspx
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17072665
Thanks for the answer.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 17072769
Thanks for the points.  Glad I could help.

A much better hash alternative woulld be SHA-2/SHA160, SHA256, SHA1024.

MD5 is ok for non-sensitive applications, but NIST has put it on a "don't use for criticatl applications" list.
0
 
LVL 3

Author Comment

by:IUFITS
ID: 17072817
Very good, thanks for the additonal info!  :)  I'll keep that in mind.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question