5

Forgive me if this is a noob question - My CS education is a somewhat incomplete

Basically, I need a way to hash an input, so that someone seeing the output doesn't see the original input value. Security is not an issue, and I need to be able to make this unique across about 1 million inputs.

Originally I was using a hashcode() just fine, but when I started getting to around 1 million inputs, I had very high collision.

Can someone help me conceptually understand where I should look to approach this problem? Should I be trying to write my own function to do this? I thought I could just find a better hash function, like hashcode(), but I only find stuff about writing my own.

  • 2
    you'll need only ~40 bits in the hash output, (unless I remember the birthday paradox wrong) – ratchet freak Oct 27 '14 at 21:30
  • 2
    Just use SHA-2. – user7043 Oct 27 '14 at 21:33
  • 1
    See the answers here: stackoverflow.com/q/5531455/1345223 – user53019 Oct 27 '14 at 21:37
  • 1
    As an aside, give Which hashing algorithm is best for uniqueness and speed? a look. While its lowercase sample size is smaller than yours (only ~200k entries), the ideas and concepts within the post may be of use in evaluating solutions. – user40980 Oct 27 '14 at 21:42
  • 2
    @PeriataBreatta the answer in that question goes into extreme detail of analysis on the uniqueness and distribution of various hashing algorithms. It should have more than enough information to help the asker here choose an algorithm with a good distribution. – Jimmy Hoffa Oct 28 '14 at 6:04

Browse other questions tagged or ask your own question.