hashing

Have a good hash function for a C++ hash table?

Hello stackoverflowers :) I am in need of a performance-oriented hash function implementation in C++ for a hash table that I will be coding. I looked around already and only found questions asking what's a good hash function "in general". I've considered CRC32 (but where to find good implementation?) and a few cryptography algorithms. M...

An open adressed hash table using AVL trees with quadratic probing.

Each position in the table contains an AVL tree. Now, insertion and deletion work fine, but the problem comes with the deletion. Suppose I have this: [0]: a0 b0 c0 [1]: d0 e0 f0 [2]: g2 h0 i0 The number indicates that the associated elements have collided, so they have been moved to the other positions by the probing. Now, suppose I'd...

Good way to hash a float vector?

I am well aware of all the problems involved in comparing floats. This is exactly the reason for this question. I'm looking to create a fast hash table for values that are 3D vectors (3 floats - x,y,z). It can be assumed that the length of the vector is always 1.0 (sqrt(x*x+y*y+z*z) is 1.0) Essentially this means that I'm looking for ...

Preventing fraudulent submission to a scoreboard

I'm working on the backend for a Flash game and I need to secure the data going into the scoreboard. The game is going to be hosted on many sites in a banner ad, the user will play the game in the advert then click through to the main site to save their details. At the moment I am thinking along the lines of this User plays the game ...

Default implementation for Object.GetHashCode()

Does anyone know or have an idea on how the default implementation for GetHashCode() works? And does it handle structures, classes, arrays, etc efficiently and well enough? Trying to decide under what cases I should pack my own and what cases I can safely rely on the default implementation to do well. Don't want to reinvent the wheel if...

GetHashCode for comparison and equality

Hi, I have a program which i should ensure that a URL exist or not, if exists in the database, i should select the ID if not i should insert it to the database. I have a question, Is GetHashCode is a good approach to save the hash code in the database and just compare the hash codes? Can I be sure there is no exception which 2 or more ...

Better hashing than SHA1

I'm working on an application and I need to store the users password, so I'm thinking I'll store it in the current-user class of the registry, but I also want to hash it for the obvious reason, and I've seen news items that state that SHA1 has been cracked, is there a better (uncracked) hashing algorithm available in the "standard" syste...

How does a hash table work?

I'm looking for an explanation of how a hashtable works - in plain English for a simpleton like me! For example I know it takes the key, calculates the hash (how?) and then performs some kind of modulo to work out where it lies in the array that the value is stored, but that's where my knowledge stops. Could anyone clarify the process. ...

GetHashCode Extension Method

After reading all the questions and answers on StackOverflow concerning overriding GetHashCode() I wrote the following extension method for easy and convenient overriding of GetHashCode(): public static class ObjectExtensions { private const int _seedPrimeNumber = 691; private const int _fieldPrimeNumber = 397; public static...

Linking Two Multi-Dimensional arrays using pointers

I need to basically merge a Binary Heap, and Linear Probing Hashtable to make a "compound" data structure, which has the functionality of a heap, with the sorting power of a hashtable. What I need to do is create 2 2 dimension arrays for each data structure (Binary Heap, and Hash) then link them to each other with pointers so that when ...

Is using a 'salt' all that good?

I don't claim to be an expert in security but it seems to me that adding a salt doesn't really make a huge difference. For example, if the password of the user is john1970 and the salt is 123456, this means that the password is 123456john1970, while this makes things harder for an attacker (if using a dictionary attack, e.g. rainbow tab...

Fast Cross-Platform C/C++ Hashing Library

What's a high performance hashing library that's also cross platform for C/C++. For algorithms such as MD5, SHA1, CRC32 and Adler32. I initially had the impression that Boost had these, but apparently not (yet). The most promising one I have found so far is Crypto++, any other suggestions? http://www.cryptopp.com/ This seems to be qui...

C# Create a hash for a byte array or image

Duplicate How do I generate a hashcode from a byte array in c# In C#, I need to create a Hash of an image to ensure it is unique in storage. I can easily convert it to a byte array, but unsure how to proceed from there. Are there any classes in the .NET framework that can assist me, or is anyone aware of some efficient algori...

Which hash function should I choose?

The .NET framework ships with 6 different hashing algorithms: MD5: 16 bytes (Time to hash 500MB: 1462 ms) SHA1: 20 bytes (1644 ms) SHA256: 32 bytes (5618 ms) SHA384: 48 bytes (3839 ms) SHA512: 64 bytes (3820 ms) RIPEMD: 20 bytes (7066 ms) Each of these functions performs differently; MD5 being the fastest and RIPEMD being the slowes...

Computing MD5SUM of large files in C#

I am using following code to compute MD5SUM of a file - byte[] b = System.IO.File.ReadAllBytes(file); string sum = BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(b)); This works fine normally, but if I encounter a large file (~1GB) - e.g. an iso image or a DVD VOB file - I get an Out of Memory exception. Though, I ...

Does any published research indicate that preimage attacks on MD5 are imminent?

I keep on reading on SO that MD5 is broken, bust, obsolete and never to be used. That angers me. The fact is that collision attacks on MD5 are now fairly easy. Some people have collision attacks down to an art and can even us use them to predict elections. I find most of the examples MD5 "brokeness" less interesting. Even the famous C...

Generate a commutative hash based on three sets of numbers?

I need to generate a commutative hash based on three sets of "score" structs. Each score has a "start", an "end" and a "number". Both start and end are usually huge numbers (8-9 digits) but number is just from 1 to 4. I need them to be commutative so the order does not matter. I'm using XOR at the moment but it seems to be giving bad ...

Strategies for authenticating users one time without pre-shared identifier.

I am creating a script that takes a list of names and email addresses and sends an email inviting them to register for our department's secure website. The list of names and emails are available on a public facing page on the same site. I need a way to give them a unique token that will identify them when they follow a link in the emai...

How to store passwords *correctly*?

An article that I stumbled upon here in SO provided links to other articles which in turn provided links to even more articles etc. And in the end I was left completely stumped - so what is the best way to store passwords in the DB? From what I can put together you should: Use a long (at least 128 fully random bits) salt, which is sto...

Using Hash Maps to represent an extremely large data source

I have a very large possible data set that I am trying to visualize at once. The set itself consists of hundreds of thousands of segments, each of which is mapped to an id. I have received a second data source that gives more real-time information for each segment, but the id's do not correspond to the id's I have. I have a 1:1 mappin...