murmurhash3_seed.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Hash: MurmurHash3 seed
  3. --FILE--
  4. <?php
  5. $ctx = hash_init("murmur3f", options: ["seed" => 42]);
  6. hash_update($ctx, "Two");
  7. hash_update($ctx, " hashes");
  8. hash_update($ctx, " meet");
  9. hash_update($ctx, " in");
  10. hash_update($ctx, " a");
  11. hash_update($ctx, " bar.");
  12. $h0 = hash_final($ctx);
  13. echo $h0, "\n";
  14. $h0 = hash("murmur3f", "Two hashes meet in a bar.", options: ["seed" => 42]);
  15. echo $h0, "\n";
  16. $ctx = hash_init("murmur3c", options: ["seed" => 106]);
  17. hash_update($ctx, "Two");
  18. hash_update($ctx, " hashes");
  19. hash_update($ctx, " meet");
  20. hash_update($ctx, " in");
  21. hash_update($ctx, " a");
  22. hash_update($ctx, " bar.");
  23. $h0 = hash_final($ctx);
  24. echo $h0, "\n";
  25. $h0 = hash("murmur3c", "Two hashes meet in a bar.", options: ["seed" => 106]);
  26. echo $h0, "\n";
  27. $ctx = hash_init("murmur3a", options: ["seed" => 2345]);
  28. hash_update($ctx, "Two");
  29. hash_update($ctx, " hashes");
  30. hash_update($ctx, " meet");
  31. hash_update($ctx, " in");
  32. hash_update($ctx, " a");
  33. hash_update($ctx, " bar.");
  34. $h0 = hash_final($ctx);
  35. echo $h0, "\n";
  36. $h0 = hash("murmur3a", "Two hashes meet in a bar.", options: ["seed" => 2345]);
  37. echo $h0, "\n";
  38. ?>
  39. --EXPECT--
  40. 95855f9be0db784a5c37e878c4a4dcee
  41. 95855f9be0db784a5c37e878c4a4dcee
  42. f64c9eb40287fa686575163893e283b2
  43. f64c9eb40287fa686575163893e283b2
  44. 7f7ec59b
  45. 7f7ec59b