I am writing a code that will find collisions for std::hash<std::string>
and trying to reverse some of hash calculation steps.
There is such a multiplication in std::hash
implementation.
size_t hash2 = shift_mix(hash1) * mul;
I know hash2
- from previous step, also I know mul
- it's constant value = 0xc6a4a7935bd1e995UL
.
shift_mix(hash1) * mul
causes overflow (hash2 / mul = 0
), so it takes only last 64 bits of multiplication result.
So, I need a way to find many variants of shift_mix(hash1)
which satisfy equality. What is the best way to do it? Probably somehow use __int128_t
?