@@ -13,43 +13,60 @@ $password = 'password';
13
13
$ salt = 'salt ' ;
14
14
15
15
echo "\n-- Testing hash_pbkdf2() function with invalid hash algorithm -- \n" ;
16
- var_dump (hash_pbkdf2 ('foo ' , $ password , $ salt , 1 ));
16
+ try {
17
+ var_dump (hash_pbkdf2 ('foo ' , $ password , $ salt , 1 ));
18
+ }
19
+ catch (\Error $ e ) {
20
+ echo $ e ->getMessage () . "\n" ;
21
+ }
22
+
17
23
18
24
echo "\n-- Testing hash_pbkdf2() function with non-cryptographic hash algorithm -- \n" ;
19
- var_dump (hash_pbkdf2 ('crc32 ' , $ password , $ salt , 1 ));
25
+ try {
26
+ var_dump (hash_pbkdf2 ('crc32 ' , $ password , $ salt , 1 ));
27
+ }
28
+ catch (\Error $ e ) {
29
+ echo $ e ->getMessage () . "\n" ;
30
+ }
20
31
21
32
echo "\n-- Testing hash_pbkdf2() function with invalid iterations -- \n" ;
22
- var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , 0 ));
23
- var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , -1 ));
33
+ try {
34
+ var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , 0 ));
35
+ }
36
+ catch (\Error $ e ) {
37
+ echo $ e ->getMessage () . "\n" ;
38
+ }
39
+
40
+ try {
41
+ var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , -1 ));
42
+ }
43
+ catch (\Error $ e ) {
44
+ echo $ e ->getMessage () . "\n" ;
45
+ }
24
46
25
47
echo "\n-- Testing hash_pbkdf2() function with invalid length -- \n" ;
26
- var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , 1 , -1 ));
48
+ try {
49
+ var_dump (hash_pbkdf2 ('md5 ' , $ password , $ salt , 1 , -1 ));
50
+ }
51
+ catch (\Error $ e ) {
52
+ echo $ e ->getMessage () . "\n" ;
53
+ }
27
54
28
55
?>
29
56
===Done===
30
- --EXPECTF --
57
+ --EXPECT --
31
58
*** Testing hash_pbkdf2() : error conditions ***
32
59
33
60
-- Testing hash_pbkdf2() function with invalid hash algorithm --
34
-
35
- Warning: hash_pbkdf2(): Unknown hashing algorithm: foo in %s on line %d
36
- bool(false)
61
+ Unknown hashing algorithm: foo
37
62
38
63
-- Testing hash_pbkdf2() function with non-cryptographic hash algorithm --
39
-
40
- Warning: hash_pbkdf2(): Non-cryptographic hashing algorithm: crc32 in %s on line %d
41
- bool(false)
64
+ Non-cryptographic hashing algorithm: crc32
42
65
43
66
-- Testing hash_pbkdf2() function with invalid iterations --
44
-
45
- Warning: hash_pbkdf2(): Iterations must be a positive integer: 0 in %s on line %d
46
- bool(false)
47
-
48
- Warning: hash_pbkdf2(): Iterations must be a positive integer: -1 in %s on line %d
49
- bool(false)
67
+ Iterations must be a positive integer: 0
68
+ Iterations must be a positive integer: -1
50
69
51
70
-- Testing hash_pbkdf2() function with invalid length --
52
-
53
- Warning: hash_pbkdf2(): Length must be greater than or equal to 0: -1 in %s on line %d
54
- bool(false)
71
+ Length must be greater than or equal to 0: -1
55
72
===Done===
0 commit comments