3 ms·
For anyone else that's curious, it's a pretty simple change: 23.1 --- a/Modules/datetimemodule.c 23.2 +++ b/Modules/datetimemodule.c 23.3 @@ -2566,
by bmm6o 15y ago
For anyone else that's curious, it's a pretty simple change:
23.1 --- a/Modules/datetimemodule.c
23.2 +++ b/Modules/datetimemodule.c
23.3 @@ -2566,10 +2566,12 @@ generic_hash(unsigned char *data, int len)
23.4 register long x;
23.5
23.6 p = (unsigned char *) data;
23.7 - x = *p << 7;
23.8 + x = _Py_HashSecret.prefix;
23.9 + x ^= *p << 7;
23.10 while (--len >= 0)
23.11 x = (1000003*x) ^ *p++;
23.12 x ^= len;
23.13 + x ^= _Py_HashSecret.suffix;
23.14 if (x == -1)
23.15 x = -2;
The hash computation is initialized with a global random value, and a second one is xored in at the end. (-1 isn't allowed as a hash, since it's the sentinel value that indicates the hash hasn't been computed yet.)