Skip to content

Commit

Permalink
Added murmurhash3_int function to retrieve non base-converted hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
lastguest committed Jul 28, 2015
1 parent 37a3c45 commit 7548fe1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions murmurhash3.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @return number 32-bit (base 32 converted) positive integer hash
*/

function murmurhash3($key,$seed=0){
function murmurhash3_int($key,$seed=0){
$klen = strlen($key);
$h1 = $seed;
for ($i=0,$bytes=$klen-($remainder=$klen&3) ; $i<$bytes ; ) {
Expand Down Expand Up @@ -48,5 +48,9 @@ function murmurhash3($key,$seed=0){
$h1 ^= $h1 >> 13;
$h1 = (((($h1 & 0xffff) * 0xc2b2ae35) + (((($h1 >> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
$h1 ^= $h1 >> 16;
return base_convert($h1,10,32);
return $h1;
}

function murmurhash3($key,$seed=0){
return base_convert(murmurhash3_int($key,$seed),10,32);
}

0 comments on commit 7548fe1

Please sign in to comment.