6 ms·
> Even when I've not needed a cryptographic hash, I've still used one, because why not? Performance. Take a look at djb's (non-cryptographic) hash, with a con
by zeveb 10y ago
> Even when I've not needed a cryptographic hash, I've still used one, because why not?
Performance. Take a look at djb's (non-cryptographic) hash, with a constant multiplier chosen to be implemented with a shift and an add — that's the level of performance a non-cryptographic hash (e.g. for hash tables & similar purposes) needs.
https://gist.github.com/hmic/1676398 https://gist.github.com/hmic/1676398
- ticki_ 10y agoPlease don't. DJB2 is a poor hash function. It's similar to FNV: Entropy only moves upwards, so flipping higher bits doesn't affect lower bits. In other words, you risk mapping `n` and `-n` to the same value under some modulus.