Hacker News new | ask | show | jobs
by rokob 2937 days ago
The hasher in the standard library is defined here: https://github.com/apple/swift/blob/master/stdlib/public/cor...

with some explanation for where the seed comes from here:

https://github.com/apple/swift/blob/master/stdlib/public/cor...

Within that code you will see references to Core which by default is this:

https://github.com/apple/swift/blob/82226642c2459c0f5d2054fe...

So you can see the hash function itself is deterministic given the seed it is initialized with. And the seed is generated at process start time during static initialization in C++ so it is effectively a constant for the lifetime of the process.

You can see in the code that there is a way to make hashing fully deterministic by making the seed generation not use random numbers, but it is ill-advised for a variety of security reasons.