Click here to Skip to main content
15,888,267 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hey all,

I need a good hash function (for strings) that will produce the same hash value for a specific string on different platforms,

My app invovles a server farm, and a "bank" server,
Each server produces hash "keys" for strings and the bank stores the keys.
The Servers may later ask the bank if a specific key [hash value] exists in the bank and if so, do SomeThings() etc.

So the hash function hash to produce the same values on the bank server and on each of the servers on the farm (as well as PC who occasionally connect as clients and operate in a similar way to the servers on the farm.)

** All OS are windows (2k8_R2 or Win7) 64 bit

Thoughts:
- Will SHA-2, GetHashCode() or some other off-the-shelf standard, work well for me?
- Do I have to implement my own hash function in order to overcome the cross platform issue? if so, any recomendation for a good one.


Thanks a bunch,
Edo
Posted
Comments
AmitGajjar 26-Aug-12 4:25am    
really sorry to say but if you do not have idea about all this then how can you build software for a bank ? apologies for asking you such a rude question.
Joezer BH 27-Aug-12 2:33am    
Hi Amit,

Quite a language you have there, but that's fine.
I have an idea about those things but, there are ditch holes - e.g. using SHA with the .NET implementation turned out to give different values on different platforms (such as different OS, or 64\32 bit etc) and since the keys are generated on different platforms I need to know that the hashing algorithm provides identical values ON DIFFERENT PLATFORMS.

The "Bank" the the server holding the keys and objects related to those keys - hence "Bank" ...

The client has nothing to do with banking (as far as I know)
;)
AmitGajjar 27-Aug-12 2:39am    
What if you are creating a service hosted on one platform and that will generate hash for you? in that case each time you will get identical key.
Joezer BH 30-Aug-12 6:54am    
Conceptually that's a good idea @amitgajjar!
:)

However, not suiting for my situation :(
I am running a several minute computation on each server of my server farm over and over (several million times) with different params each time.
The set of params which is the string I need to hash, is not so short, so sending them over to the server to compute the hash will bottle-neck the server.

So I figures the guys here at CodeProject will give me a hand ;)
AmitGajjar 30-Aug-12 6:57am    
if you do not want immediate hash value then you can call service with delayed call. create one xml file locally and after particular time call service for hashing all value inside xml. once you got hash data in xml, you can read it.

1 solution

 
Share this answer
 
Comments
Espen Harlinn 26-Aug-12 8:11am    
Implemented in both .Net and mono, good choice :-D
Kenneth Haugland 26-Aug-12 8:11am    
Thanks Espen :)
Joezer BH 27-Aug-12 3:28am    
Hi Kenneth,

I need a hashing function, does RSA provide this kind of functionality?
Hashing provides the ability to resemble a looooong string in a short key. That's what I need

e.g. a looooong set of configuration settings that is stored, in a bank,
when a client wishes to get this loooong set of configurations settings, it hashes them (and thus getting a short key that represents those settings, kind'a like CRC but not quite) with this short key, it can ask the "bank" server,

"Hey do you have the conf sett represented by the key 'aksdjhfalksjdhfalkjhf'?"

the problem with some hashing functions is (as I answered amitgajjar above) is that they don't always produce the same values on different platforms.
so for a single server they will be just fine, but for a system with many different platforms you'll have to do better ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900