[fpc-pascal] Pointer hashing

Marco van de Voort marcov at stack.nl
Mon Jan 30 06:49:24 CET 2017


In our previous episode, Ryan Joseph said:
> 
> unsigned int hash(unsigned int x) {
>     x = ((x >> 16) ^ x) * 0x45d9f3b;
>     x = ((x >> 16) ^ x) * 0x45d9f3b;
>     x = (x >> 16) ^ x;
>     return x;
> }
> 
> function Hash (x: PtrUInt): PtrUInt;
> begin
>   x := (Power((x shr 16), x)) * $45d9f3b;
>   x := (Power((x shr 16), x)) * $45d9f3b;
>   x := Power((x shr 16), x);
>   result := x;
> end;

- In C operator crypto lingo, ^ is xor, not exponentiation.
- the lower 3,4 bits of heap pointer are usually not used,
- for 64-bit you probably have to chage this and have more terms also with
- shr 32 and 48




More information about the fpc-pascal mailing list