Skip to content

Commit 55f8298

Browse files
author
Stefano Azzolini
committed
PSR-4 Support
1 parent cd1360f commit 55f8298

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# MurmurHash.PHP
1+
# MurmurHash3
22

33
PHP Implementation of MurmurHash3
44

@@ -9,6 +9,22 @@ More information about these algorithms can be found at:
99

1010
Porting of the MurmurHash3 JavaScript version created by Gary Court (https://github.com/garycourt/murmurhash-js)
1111

12+
## Installation
13+
Use [composer](https://getcomposer.org/download/) :
14+
15+
```bash
16+
composer require lastguest/murmurhash
17+
```
18+
19+
## Usage
20+
21+
```php
22+
<?php
23+
echo murmurhash3("Hello World");
24+
// cnd0ue
25+
```
26+
27+
1228
## License (MIT)
1329

1430
Copyright (c) 2011 Stefano Azzolini

composer.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "lastguest/murmurhash",
3+
"description": "MurmurHash3 Hash",
4+
"homepage": "https://github.com/lastguest/murmurhash-php",
5+
"keywords": [ "hash","hashing", "murmur" ],
6+
"type": "library",
7+
"license": "MIT",
8+
"require": {
9+
"php": ">=4.3"
10+
},
11+
"authors": [
12+
{
13+
"name": "Stefano Azzolini",
14+
"email": "[email protected]",
15+
"homepage": "https://github.com/lastguest/murmurhash-php"
16+
}
17+
],
18+
"autoload": {
19+
"files": [
20+
"murmurhash3.php"
21+
]
22+
}
23+
}

murmurhash3_32_gc.php murmurhash3.php

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

18-
function murmurhash3_32_gc($key,$seed=0){
18+
function murmurhash3($key,$seed=0){
1919
$klen = strlen($key);
2020
$h1 = $seed;
2121
for ($i=0,$bytes=$klen-($remainder=$klen&3) ; $i<$bytes ; ) {
2222
$k1 = ((ord($key[$i]) & 0xff))
23-
| ((ord($key[++$i]) & 0xff) << 8)
23+
| ((ord($key[++$i]) & 0xff) << 8)
2424
| ((ord($key[++$i]) & 0xff) << 16)
2525
| ((ord($key[++$i]) & 0xff) << 24);
2626
++$i;

0 commit comments

Comments
 (0)