Solved

Is GetHashCode for a file unique?

Posted on 2006-07-09
4
720 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
  • 2
  • 2
4 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
Comment Utility
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
Comment Utility
Thanks for the answer.
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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
Comment Utility
Very good, thanks for the additonal info!  :)  I'll keep that in mind.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
DataGridView 2 29
Combobox, SelectedIndexChanged Get Index 2 21
visual Basic Net vs c# net 8 54
.net VBA word safemode 1 23
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now