@@ -3,6 +3,13 @@ Hash: xxHash secret
33--FILE--
44<?php
55
6+ class StringableThrowingClass {
7+ public function __toString (): string {
8+ throw new Exception ('exception in __toString ' );
9+ return '' ;
10+ }
11+ }
12+
613foreach (["xxh3 " , "xxh128 " ] as $ a ) {
714
815 //$secret = random_bytes(256);
@@ -14,6 +21,12 @@ foreach (["xxh3", "xxh128"] as $a) {
1421 var_dump ($ e ->getMessage ());
1522 }
1623
24+ try {
25+ $ ctx = hash_init ($ a , options: ["secret " => new StringableThrowingClass ()]);
26+ } catch (Throwable $ e ) {
27+ var_dump ($ e ->getMessage ());
28+ }
29+
1730 try {
1831 $ ctx = hash_init ($ a , options: ["secret " => str_repeat ('a ' , 17 )]);
1932 } catch (Throwable $ e ) {
@@ -35,8 +48,10 @@ foreach (["xxh3", "xxh128"] as $a) {
3548?>
3649--EXPECT--
3750string(67) "xxh3: Only one of seed or secret is to be passed for initialization"
51+ string(23) "exception in __toString"
3852string(57) "xxh3: Secret length must be >= 136 bytes, 17 bytes passed"
39538028aa834c03557a == 8028aa834c03557a == true
4054string(69) "xxh128: Only one of seed or secret is to be passed for initialization"
55+ string(23) "exception in __toString"
4156string(59) "xxh128: Secret length must be >= 136 bytes, 17 bytes passed"
425754279097795e7218093a05d4d781cbb9 == 54279097795e7218093a05d4d781cbb9 == true
0 commit comments