xref: /PHP-8.1/ext/hash/tests/murmurhash3.phpt (revision 72e91e9f)
1--TEST--
2Hash: MurmurHash3 test
3--FILE--
4<?php
5
6$h = hash("murmur3a", "foo");
7echo $h, "\n";
8
9$h = hash("murmur3c", "Two hashes meet in a bar", false);
10echo $h, "\n";
11$h = hash("murmur3c", "hash me!");
12echo $h, "\n";
13
14$h = hash("murmur3f", "Two hashes meet in a bar", false);
15echo $h, "\n";
16$h = hash("murmur3f", "hash me!");
17echo $h, "\n";
18
19$ctx = hash_init("murmur3a");
20hash_update($ctx, "hello");
21hash_update($ctx, " there");
22$h0 = hash_final($ctx);
23$h1 = hash("murmur3a", "hello there");
24echo $h0, " ", $h1, "\n";
25
26$ctx = hash_init("murmur3c");
27hash_update($ctx, "hello");
28hash_update($ctx, " there");
29$h0 = hash_final($ctx);
30$h1 = hash("murmur3c", "hello there");
31echo $h0, " ", $h1, "\n";
32
33$ctx = hash_init("murmur3f");
34hash_update($ctx, "hello");
35hash_update($ctx, " there");
36$h0 = hash_final($ctx);
37$h1 = hash("murmur3f", "hello there");
38echo $h0, " ", $h1, "\n";
39
40?>
41--EXPECT--
42f6a5c420
438036c2707453c6f37348142be7eaf75c
44c7009299985a5627a9280372a9280372
4540256ed26fa6ece7785092ed33c8b659
46c43668294e89db0ba5772846e5804467
476440964d 6440964d
482bcadca212d62deb69712a721e593089 2bcadca212d62deb69712a721e593089
4981514cc240f57a165c95eb63f9c0eedf 81514cc240f57a165c95eb63f9c0eedf
50