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
3
votes
1 answer

What has the least collisions for a non unique str: md5 or sha1

I want to create a unique hash for a given string and I was wondering if there is a difference in duplicate hashes for md5 and sha1. Lets for the sake of argument assume the following code: foo = "gdfgkldng" bar = "fdsfdsf" md5(foo) >>>>…
RickyA
  • 15,465
  • 5
  • 71
  • 95
2
votes
1 answer

Creating unique integer/float hashs of a million short strings

Most applications, especially databases, can sort and filter by small integers or floats much faster than they can do string comparisons. Therefore I'm wondering if there is a hashing function that I can use to return a 32bit or 64bit number of a…
Xeoncross
  • 55,620
  • 80
  • 262
  • 364
2
votes
2 answers

how can there be same md5 value for two different length strings

I have an md5 function which i have confirmed to work well for both files and strings. But when i use it on variable sized chunks of very large files it generates md5 values which are the same but the size of the chunks is different. I wonder if…
John
  • 794
  • 2
  • 18
  • 34
2
votes
5 answers

Why doesn't my HashTable allow key collisions?

I read that HashTable can map same key to multiple values. That's what collision is. Now I run the program like this: Dictionary hTable = new Hashtable(); hTable.put("a", "aa"); hTable.put("a",…
user900721
  • 1,417
  • 4
  • 17
  • 29
2
votes
1 answer

Is there any possibility that std::unordered_map collides?

I seen a post in here that you could "meet with the Birthday problem." while using std::unordered_map When should I use unordered_map and not std::map Which really surprises me, that is the same that saying std::unordered_map is unsafe to use. Is…
Jonnas Kaf
  • 67
  • 5
2
votes
0 answers

Java, how to hash a string with low collision probability, specify characters allowed in output to decrease this

Is there any way to hash a string and specify the characters allowed in the output, or a better approach to avoid collisions when producing a hash of 8 characters in length. I am running into a situation where I am seeing a collision with my current…
tpngr999
  • 21
  • 2
2
votes
0 answers

SHA-1 bijection

If SHA-1 was tried on each and every possible 160-bit string, could it happen that it produces a hash twice, i.e. could it happen that it wont produce a certain hash? In other words, for every 160-bit string, does SHA-1 produce exactly one hash?
Ecir Hana
  • 10,864
  • 13
  • 67
  • 117
2
votes
1 answer

How do I properly calculate the load factor of a hash table that uses separate chaining?

I'm working with hash tables that use separate chaining as a collision resolution technique. I do know that the general formula is N/table_length, where N is the number of items currently in the table. I'm a bit confused by the denominator. Would it…
Adam G
  • 145
  • 1
  • 1
  • 9
2
votes
1 answer

Why would one add a constant to hashCode()?

I'm new to Java, and I've recently learned about hashCode(). On the wikipedia article about Java hashCode(), there is the following example of a hashCode() method: public class Employee { int employeeId; String name; …
2
votes
1 answer

Distinguishing cryptographic properties: hiding and collision resistance

I saw from Another question the following definitions, which clarifies somewhat: Collision-resistance: Given: x and h(x) Hard to find: y that is distinct from x and such that h(y)=h(x). Hiding: Given: h(r|x), where r|x is the concatenation of r and…
Haukland
  • 677
  • 8
  • 25
2
votes
2 answers

C++ Hash Table - How is collision for unordered_map with custom data type as keys resolved?

I have defined a class called Point which is to be used as a key inside an unordered_map. So, I have provided an operator== function inside the class and I have also provided a template specialization for std::hash. Based on my research, these are…
skr
  • 914
  • 3
  • 18
  • 35
2
votes
1 answer

Double hashing using composite numbers in second hash function

I realize that the best practice is to use the largest prime number (smaller then the size of the array) in the mod function of the second hash function is best practice. But my question is regarding the use of numbers that are not prime…
Immanuel
  • 172
  • 1
  • 13
2
votes
1 answer

Collision rate of two 32-bit hashes vs one 64-bit hash? (uncorrelated?)

I have seen a couple questions that ask "do two 16-bit hashes have the same collision rate as a 32-bit hash?" or "do two 32-bit hashes have the same collision rate as a 64-bit hash?" And it seems like the answer is "yes, if they're decent hash…
bryc
  • 12,710
  • 6
  • 41
  • 61
2
votes
3 answers

Hashing multiple values in golang

I'm currently working on an application in go that needs to cache different resources. Different types of resources have handlers that will know what data is relevant to determine, if we have to rebuild a resource or if we can fetch it from cache.…
Gellweiler
  • 751
  • 1
  • 12
  • 25
2
votes
2 answers

Collision Attacks, Message Digests and a Possible solution

I've been doing some preliminary research in the area of message digests. Specifically collision attacks of cryptographic hash functions such as MD5 and SHA-1, such as the Postscript example and X.509 certificate duplicate. From what I can tell in…
Matthieu N.