Reputation: 4177
I'm trying to hash some values and use the hashed value as an index in my database. Not having collisions is very important, which is why I'm going with md5. Having 128 bits, gives me more than the space I need to not worry about collisions (I know that md5 is not collision safe).
Anyways, how can I store the result of the md5 in a database and so that I can index it and retrieve it quickly? I was thinking of having two Long variables where one would hold the value of the first 64 bits and the other the second 64 bits and use both keys as an index on my database. But I need a fast way for doing this... what would be the fastest way ?
I don't think storing the md5 hashed value as a byte array will help much when I need indexing.
Upvotes: 3
Views: 1050
Reputation: 13097
Just store it as a string (VARCHAR) and let your DB index that. This is the easiest solution, and you'll get the performance boost from the index.
Upvotes: 3