Hacker News new | ask | show | jobs
by bbatha 2935 days ago
The hashing algorithm can be deterministic however hashing relies on a seed. In most cases you want that to be random to prevent certain side channel attacks. For swift, hashing will be deterministic for the lifetime of the program.
2 comments

That makes sense. I was thinking in terms of global lookup keys, which would require hashes to persist across runs. When thinking in terms of object equality, the hashes need only live as long as the objects themselves. Namely, for the lifetime of the program.
wait, hashing relies on a seed?! isn't that a salt/pepper?

to be "deterministic for the lifetime of the program" sounds like a pepper is being applied, not that the hash algorithm is different.

This is a more accurate description. The hashing algorithm is 100% deterministic, but the inputs include a random seed from the start of the program to prevent various side channel attacks and to prevent folks from erroneously relying on hashmap ordering.