In your case, I would not use any cryptographic hash functions (e.g. MD5, SHA), since they were designed with security in mind: they basically want to make it as difficult as possible to find two different lines with the same hash. I think this will not be a problem in your case. (the probability of random collisions is inherent to hashing, of course)
I would not suggest using String.GetHashCode() , as the implementation is unknown, and MSDN says that it may vary between different versions of the framework. Even the results between x86 and x64 versions may vary. Thus, you will encounter problems when trying to access the same database using a new (or different) version of the .NET framework.
I found the hashCode Java implementation algorithm on Wikipedia ( here ), it seems pretty simple to implement. Even a simple implementation will be faster than an MD5 or SHA imo implementation. You can also use long values ββthat reduce the chance of collisions.
There is also a brief analysis of the .NET implementation of GetHashCode here (not the algorithm itself, but some implementation details), you can also use this one think. (or try to implement the Java version in a similar way ...)
MartinStettner
source share