I know that one of the most important features of hashing algorithms, is that minor changes in the input should reflect great change in the hash itself (the avalanche effect), but I'm currently searching for a solution that doesn't implement this.

I've read this answer on the cryptography stackexchange, but it doesn't seem to offer exactly what I need.

I still need the input to be obscured so that reversion is impossible/improbable, but I'd like for similar input values to output similar hashes.

I imagine an algorithm with something like this (pseudo-example):

Input: Is this possible?
Output: 5e2a9d8a8f02c07c20142a571f1785c2

Input: Is this impossible?
Output: 5e2a9d8a8f02c07c20142a671f1785d2

Does something like this exist at all?

  • 5
    You want something like locality-sensitive hashing. Aug 5, 2018 at 11:03
  • Yes @Deduplicator that is exactly what I want! Feel free to post an answer I can accept :)
    – Daniel
    Aug 5, 2018 at 11:10
  • Just add the character values? Aug 5, 2018 at 11:54
  • 1
    @MartinMaat If I added the ASCII values of the characters the sentence Power to the people would be 1814 and I love giant tigers! would be 1825 so those sentences would be considered very similar (although they aren't!)
    – Daniel
    Aug 5, 2018 at 12:04
  • 1
    ASCII characters don't reflect the difference you're looking for very well (e.g. 'a' to 'A' is a larger change than 'a' to 'x'). Do the strings have any structure you could leverage? Do they have a maximum length? How large is your alphabet? Do you have a set of possible words? Is 'were you there' and 'you were there' very similar or very different (i.e. how important is the position of words)? I think order is extremely difficult, because you need to include a character's/word's position without accidentally giving some parts of the string more weight than others. How about 'WERE YOU THERE'?
    – doubleYou
    Aug 11, 2018 at 10:57


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.