xref: /php-src/ext/hash/tests/mhash_001.phpt (revision 2b10cd1b)
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: Constant MHASH_MD5 is deprecated in %s on line %d
39
40Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
41MHASH_MD5
42ok
43
44
45Deprecated: Constant MHASH_SHA1 is deprecated in %s on line %d
46
47Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
48MHASH_SHA1
49ok
50
51
52Deprecated: Constant MHASH_HAVAL256 is deprecated in %s on line %d
53
54Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
55MHASH_HAVAL256
56ok
57
58
59Deprecated: Constant MHASH_HAVAL192 is deprecated in %s on line %d
60
61Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
62MHASH_HAVAL192
63ok
64
65
66Deprecated: Constant MHASH_HAVAL224 is deprecated in %s on line %d
67
68Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
69MHASH_HAVAL224
70ok
71
72
73Deprecated: Constant MHASH_HAVAL160 is deprecated in %s on line %d
74
75Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
76MHASH_HAVAL160
77ok
78
79
80Deprecated: Constant MHASH_RIPEMD160 is deprecated in %s on line %d
81
82Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
83MHASH_RIPEMD160
84ok
85
86
87Deprecated: Constant MHASH_GOST is deprecated in %s on line %d
88
89Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
90MHASH_GOST
91ok
92
93
94Deprecated: Constant MHASH_TIGER is deprecated in %s on line %d
95
96Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
97MHASH_TIGER
98ok
99
100
101Deprecated: Constant MHASH_CRC32 is deprecated in %s on line %d
102
103Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
104MHASH_CRC32
105ok
106
107
108Deprecated: Constant MHASH_CRC32B is deprecated in %s on line %d
109
110Deprecated: Function mhash() is deprecated since 8.1 in %s on line %d
111MHASH_CRC32B
112ok
113