1

I have the need for storing key-value pairs, where the key is supposed to be unique. It will be both kept in-memory as well as in binary format on disk. The key is also part of a custom message protocol sent over TCP.

Was first thinking of not supporting what-ever size you want of the key but instead limiting it to X-chars.

Is there an applicable hashing algorithm (no need for security) that would be applicable for use instead, to reduce the length etc of the key, but still being good enough for uniqueness?

Daniel
  • 8,133
  • 5
  • 36
  • 51
  • Why not use some hash function ? Sha-256 is practically secure without collisions. – kulatamicuda Apr 21 '15 at 19:23
  • Why would you use a hash for keys instead of a simple incrementing integer? Hashes of what? The data? Why not just send the data and not bother with hashes at all? – Dour High Arch Apr 21 '15 at 19:24
  • @DourHighArch because I do not own the key, which is supposed to be unique and selected by the consumer, but I'm probably going to store the whole key anyway – Daniel Apr 21 '15 at 19:56

0 Answers0