Questions tagged [hash-collision]

a situation that occurs when two distinct pieces of data have the same hash value, checksum, fingerprint, or cryptographic digest.

See also the wiki tag.

233 questions
5
votes
3 answers

Looking for an array (vs linked list) hashtable implementation in C

I'm looking for a hashtable implementation in C that stores its objects in (twodimensional) arrays rather than linked lists. i.e. if a collision happens, the object that is causing the collision will be stored in the next free row index rather than…
kingusiu
  • 316
  • 2
  • 15
5
votes
2 answers

Can hashcodes of short string be same?

I have short Strings (less than 10 characters). I will convert it into int and use it as primary key. (I can't use String primary key because of small problems.) I know the hashcodes of Strings of infinite length can collide, but can short Strings…
Cinakyn
  • 648
  • 1
  • 7
  • 20
5
votes
2 answers

What happens in Hopscotch Hash Tables when there are more than sizeof(Neighborhood) actual hash collisions?

Relevant link: http://en.wikipedia.org/wiki/Hopscotch_hashing Hopscotch hash tables seem great, but I haven't found an answer to this question in the literature: what happens if my neighborhood size is N and (due to malfeasance or extremely bad…
5
votes
2 answers

Implementing hashtables in C++ (insertion and lazy deletion)

I am implementing a Hashtable class in C++. The collision resolution method that I am using is linear probing with lazy deletion. I have seen implementations of this but had a question with regards to the insert method. Each cell of the hashtable…
ejw
  • 53
  • 4
5
votes
2 answers

Finding collisions in hash table

I was reviewing for my data structures final exam, and I came across a question in past year's final. Having worked on it for the past three hours, I still couldn't figure out a way to solve it, except by trial and error. Here's the…
4
votes
1 answer

Dictionary/Hashmap implementation using double hashing is stuck in an infinite loop

I'm following this formula from wikipedia: H(i, k) = (H1(k) + i*H2(k)) % size and my H1 is Python's built-in hash() function. H2 is: PRIME - (H1(k) % PRIME) Unfortunately it randomly sticks in an infinite loop after a couple of execution. It…
S.B
  • 13,077
  • 10
  • 22
  • 49
4
votes
2 answers

As of 2011, what hash algo is the most suitable for message digest?

I'm a bit conflicted with an answer when I google for this, as these algos are constantly improving and new exploits are being found and new issues come up all the time... a lot of advice on what algo to use is simply old, or keeping ideas from an…
Incognito
  • 20,537
  • 15
  • 80
  • 120
4
votes
2 answers

Is double hashing collision resistant?

Double Hashing can surely provides more security than only 1 layer of hashing, but does that necessarily mean it is more collision resistant? This question in a more math form: If H is a collision resistant hash function, is H(H(x)) for some x still…
4
votes
2 answers

A couple of questions about Hash Tables

I've been reading a lot about Hash Tables and how to implement on in C and I think I have almost all the concepts in my head so I can start to code my own, I just have a couple of questions that I have yet to properly understand. As a reference,…
rfgamaral
  • 16,546
  • 57
  • 163
  • 275
4
votes
2 answers

Java hash collision probability

I'm storing a large number of objects (with unique combinations of values stored in a byte array in the object) in a hashmap (~2.8million objects) and, when checking if I have any collision of hash code (32-bit hash), I'm very surprised to see there…
Tom
  • 1,375
  • 3
  • 24
  • 45
4
votes
4 answers

Is a hash result ever the same as the source value?

This is more of a cryptography theory question, but is it possible that the result of a hash algorithm will ever be the same value as the source? For example, say I have a string: baf34551fecb48acc3da868eb85e1b6dac9de356 If I get the SHA1 hash on…
SqlRyan
  • 33,116
  • 33
  • 114
  • 199
4
votes
3 answers

Hashing image bytes with SHA-256 yields many random collisions, what am I doing wrong?

I'm using the SHA-256 algorithm to detect identical images in a database. Because we use a lot of different image formats I don't want to compute the hash directly on the file. Instead I want to extract the pixel data and compute the hash on that.…
3
votes
3 answers

How collision resistant are encryption algorithms?

How hard is it for a given ciphertext generated by a given (symmetric or asymmetric) encryption algorithm working on a plaintext/key pair, to find a different plaintext/key pair that yields the same cyphertext? And how hard is it two find two…
Johannes Gerer
  • 25,508
  • 5
  • 29
  • 35
3
votes
2 answers

Frequent hash collisions when hashing 3d coordinates

I'm trying to hash a 3d coordinate to make a unique ID for an index to a map my approach is currently return hash(x + hash(y + hash(z))); Or in c++ struct ChunkHasher { std::size_t operator()(FLOAT3 const& vec) const { return…
Jay
  • 2,553
  • 3
  • 17
  • 37
3
votes
1 answer

Why does assinging a value to the key `True` of an dictionary overwrite the value of the key `1` in the same dictionary?

For this simple Dictionary - the Key 1 and Value "apple" always print as "1: False" is there a reason for this I've overlooked? $ cat dict.py pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs) *$…
Jake Cope
  • 63
  • 7