Skip to content

Instantly share code, notes, and snippets.

@mauris
Created August 12, 2012 16:02
Show Gist options
  • Select an option

  • Save mauris/3332462 to your computer and use it in GitHub Desktop.

Select an option

Save mauris/3332462 to your computer and use it in GitHub Desktop.
hash32shiftmult PHP port
function hash32shiftmult($key){
$seed = 0x27d4eb2d; // a prime or an odd constant
$key = ($key ^ 61) ^ ($key >> 16);
$key = $key + ($key << 3);
$key = $key ^ ($key >> 4);
$key *= $seed;
$key = $key ^ ($key >> 15);
return $key;
};
@mauris
Copy link
Copy Markdown
Author

mauris commented Aug 12, 2012

Note that regular collisions are observed from the integer 6990608 and onwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment