Solved

Is GetHashCode for a file unique?

Posted on 2006-07-09
4
732 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 45

Accepted Solution

by:
aikimark earned 500 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 45

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

717 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