If it is feasible to find a shorter password which hashes for the same price as a longer password, the hashing algorithm is damaged. $endgroup$ In the event the keys are strings (or integers), a trie could be another choice. A trie is a tree, but indexed otherwise from https://conradm239flt5.homewikia.com/user