tagged [hashcode]

Generate two different strings with the same hashcode

Generate two different strings with the same hashcode I want to do some tests which require some strings with the same hash code, but not the same strings. I couldn't find any examples, so I decided t...

23 Sep at 18:2

How do I create a HashCode in .net (c#) for a string that is safe to store in a database?

How do I create a HashCode in .net (c#) for a string that is safe to store in a database? To quote from [Guidelines and rules for GetHashCode](http://ericlippert.com/2011/02/28/guidelines-and-rules-fo...

6 May at 16:35

How do I check if two Objects are equal in terms of their properties only without breaking the existing Object.Equals()?

How do I check if two Objects are equal in terms of their properties only without breaking the existing Object.Equals()? Basically, GethashCode is different even though they contain the SAME values fo...

20 Jun at 15:27

Inconsistency in Equals and GetHashCode methods

Inconsistency in Equals and GetHashCode methods After reading this question [Why do "int" and "sbyte" GetHashCode functions generate different values?](https://stackoverflow.com/questions/12501979/why...

23 May at 11:43

Java: get a unique property of an object (like hashcode, but collision proof)

Java: get a unique property of an object (like hashcode, but collision proof) I have a task for which it is necessary to generate a unique value for every object in a set. using the hashcode would be ...

4 Dec at 00:48

Hash code of string is broken in .NET Core 2.1, but works in 2.0

Hash code of string is broken in .NET Core 2.1, but works in 2.0 I recently upgraded one of my projects from .NET Core 2.0 to .NET Core 2.1. After doing so several of my tests started to fail. After n...

31 Oct at 21:19

Persistent hashcode for strings

Persistent hashcode for strings I want to generate an integer hashcode for strings, that will stay constant forever; i.e. the same string should always result in the same hashcode. The hash does not h...

25 Apr at 15:53

What is an appropriate `GetHashCode()` algorithm for a 2D point struct (avoiding clashes)

What is an appropriate `GetHashCode()` algorithm for a 2D point struct (avoiding clashes) Consider the following code: ``` struct Vec2 : IEquatable { double X,Y; public bool Equals(Vec2 other) {...

20 Apr at 18:32

How well does .NET dictionary resolve collisions?

How well does .NET dictionary resolve collisions? I have a problem with a custom object that needs to be keyed for a table. I need to generate a unique numeric key. I'm having collision problems and I...

Is Dictionary broken or should GetHashCode() only base on immutable members?

Is Dictionary broken or should GetHashCode() only base on immutable members? When an object is added to the .NET [System.Collections.Generic.Dictionary](http://msdn.microsoft.com/en-us/library/xfhwa50...

.NET unique object identifier

.NET unique object identifier Is there a way of getting a unique identifier of an instance? `GetHashCode()` is the same for the two references pointing to the same instance. However, two different ins...

23 May at 12:2

General advice and guidelines on how to properly override object.GetHashCode()

General advice and guidelines on how to properly override object.GetHashCode() According to [MSDN](http://msdn.microsoft.com/en-us/library/system.object.gethashcode.aspx), a hash function must have th...

20 Jun at 09:12

HashMap with Null Key and Null Value

HashMap with Null Key and Null Value Consider the following Code : ``` import java.util.*; class Employee { String name; public Employee(String nm) { this.name=nm; } } public class HashM...

21 Mar at 18:21

Get a file SHA256 Hash code and Checksum

Get a file SHA256 Hash code and Checksum Previously I asked a [question](https://stackoverflow.com/questions/38459428/use-a-combination-of-sha1md5) about combining SHA1+MD5 but after that I understand...

20 Jun at 09:12