xref: /PHP-8.2/ext/hash/tests/mhash_001.phpt (revision bf0c1ce1)
1--TEST--
2MHash: mhash() test
3--SKIPIF--
4<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
5--FILE--
6<?php
7
8$supported_hash_al = array(
9"MHASH_MD5"       => "2d9bdb91f94e96d9c4e2ae532acc936a",
10"MHASH_SHA1"      => "2f9341e55a9083edf5497bf83ba3db812a7de0a3",
11"MHASH_HAVAL256"  => "b255feff01ad641b27358dc7909bc695a1fca53bddfdfaf19020b275928793af",
12"MHASH_HAVAL192"  => "4ce837de481e1e30092ab2c610057094c988dfd7db1e01cd",
13"MHASH_HAVAL224"  => "5362d1856752bf2c139bb2d6fdd772b9c515c8ce5ec82695264b85e1",
14"MHASH_HAVAL160"  => "c6b36f87750b18576981bc17b4f22271947bf9cb",
15"MHASH_RIPEMD160" => "6c47435aa1d359c4b7c6af46349f0c3e1258583d",
16"MHASH_GOST"      => "101b0a2552cebdf5137cadf15147f21e55b6432935bb9c2c03c7e28d188b2d9e",
17"MHASH_TIGER"     => "953ac3799a01b9fdeb91aeab97207e67395cbb54300be00d",
18"MHASH_CRC32"     => "83041db8",
19"MHASH_CRC32B"    => "df5ab7a4"
20);
21
22$data = "This is the test of the mhash extension...";
23
24foreach ($supported_hash_al as $hash=>$wanted) {
25    $result = mhash(constant($hash), $data);
26    if (bin2hex($result)==$wanted) {
27        echo "$hash\nok\n";
28    } else {
29        echo "$hash: ";
30        var_dump($wanted);
31        echo "$hash: ";
32        var_dump(bin2hex($result));
33    }
34    echo "\n";
35}
36?>
37--EXPECTF--
38Deprecated: Function mhash() is deprecated in %s on line %d
39MHASH_MD5
40ok
41
42
43Deprecated: Function mhash() is deprecated in %s on line %d
44MHASH_SHA1
45ok
46
47
48Deprecated: Function mhash() is deprecated in %s on line %d
49MHASH_HAVAL256
50ok
51
52
53Deprecated: Function mhash() is deprecated in %s on line %d
54MHASH_HAVAL192
55ok
56
57
58Deprecated: Function mhash() is deprecated in %s on line %d
59MHASH_HAVAL224
60ok
61
62
63Deprecated: Function mhash() is deprecated in %s on line %d
64MHASH_HAVAL160
65ok
66
67
68Deprecated: Function mhash() is deprecated in %s on line %d
69MHASH_RIPEMD160
70ok
71
72
73Deprecated: Function mhash() is deprecated in %s on line %d
74MHASH_GOST
75ok
76
77
78Deprecated: Function mhash() is deprecated in %s on line %d
79MHASH_TIGER
80ok
81
82
83Deprecated: Function mhash() is deprecated in %s on line %d
84MHASH_CRC32
85ok
86
87
88Deprecated: Function mhash() is deprecated in %s on line %d
89MHASH_CRC32B
90ok
91