Skip to content

Commit 7548fe1

Browse files
committed
Added murmurhash3_int function to retrieve non base-converted hash.
1 parent 37a3c45 commit 7548fe1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

murmurhash3.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @return number 32-bit (base 32 converted) positive integer hash
1616
*/
1717

18-
function murmurhash3($key,$seed=0){
18+
function murmurhash3_int($key,$seed=0){
1919
$klen = strlen($key);
2020
$h1 = $seed;
2121
for ($i=0,$bytes=$klen-($remainder=$klen&3) ; $i<$bytes ; ) {
@@ -48,5 +48,9 @@ function murmurhash3($key,$seed=0){
4848
$h1 ^= $h1 >> 13;
4949
$h1 = (((($h1 & 0xffff) * 0xc2b2ae35) + (((($h1 >> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
5050
$h1 ^= $h1 >> 16;
51-
return base_convert($h1,10,32);
51+
return $h1;
52+
}
53+
54+
function murmurhash3($key,$seed=0){
55+
return base_convert(murmurhash3_int($key,$seed),10,32);
5256
}

0 commit comments

Comments
 (0)