Methods to reduce likelihood of a hash-based algorithm to get hacked

Revision en1, by STORMGATE078, 2020-07-15 20:29:58

After reading this, this and this, I think I understand the advantages and disadvantages of hash-based solutions to problems that involve matching strings or objects. But from what I've seen so far, almost all methods that are presented make use of the fact that the characters from the alphabet are allocated linearly (I.e.: val=ch-'a'+1;, where 'val' is the equivalent of the character in decimal format — used in calculating the hash values — , and ch is the char).

What happens if instead of using this linear method of assigning values I create a function that does that randomly (and that still makes use of a prime number and a base)? This function has to be injective and should assign an integer from the range $$$[1, base-1]$$$ (where $$$base$$$ is chosen at the beginning of the program) to each character from the given alphabet. For example, if α={'a', 'b', 'c'} and base=7, is the following distribution : f('a')=5, f('b')=1, f('c')=6, harder to hack, assuming that it has been chosen randomly at the beginning and the attacker can't reverse engineer it?

Presuming that the generated numbers are truly random (they make use of the chrono clock, the processor cycles or other external source of enthropy), is this approach actually reliable and harder to hack in general?

Thank you in advance!

Tags rolling hashes, #hack, #string-hashing


  Rev. Lang. By When Δ Comment
en2 English STORMGATE078 2020-07-15 20:31:11 0 (published)
en1 English STORMGATE078 2020-07-15 20:29:58 1529 Initial revision (saved to drafts)