According to the documentation, under dictionary:
“Dictionaries use hashes for their lookup functions.”
Can anybody tell me the length of the hash that is used for this process? I’m curious because I’m storing web session information in dictionaries and want an idea of collision rate / brute-force session ID attacks. I’m currently using a 128-bit HASH for my session identifier, and if the hash for lookups is smaller than this… then hash I store with a length longer than what is used is pointless. Thanks!
Its deliberately undocumented so we can alter it without anyone relying on the implementation detail
Haha… alright, Norman. Are you at least able to state whether it’s currently above/equal to or lower than… say… 128-bits?
The keys in the dictionary are whatever size you put in there
The internals of how the dictionary organizes the data so it can access things rapidly and still use variants as keys and keep access fast has no influence on the keys you use - nor should it
Use 128 bit or longer keys if that suits your purposes
I think I understand now. Assuming the hash is strictly for catalog purposes, and a validation that if a hash matches… that it is actually then compared to the key passed before returning a value. Anyhow, appreciate your assistance Norman.
NOTE THIS IS NOT EXACTLY HOW ITS DONE (it has a bit more to it than this but to simplify the discussion)
The internal hash is not your key - its a hash made from your key
Its signed to enable fast access to a particular “bucket” so to speak
Then that bucket has your key & values s in it and its searched for your key
Internally its still YOUR key that’s important - not the internal hashes of your key
That’s exactly what I needed verified. Thank you!
If you’re concerned about collision rate, then what you want is the bin count, not the hash size. Xojo automatically adjusts the bin count for you, but if you have extremely large dictionaries, you can set it yourself to tweak performance. But you shouldn’t really ever have to.
Variant.Hash function returns an integer. If that’S used, it may be 32 bits…
But it should not matter.