xref: /PHP-8.0/ext/hash/tests/mhash_001.phpt (revision f8d79582)
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--EXPECT--
38MHASH_MD5
39ok
40
41MHASH_SHA1
42ok
43
44MHASH_HAVAL256
45ok
46
47MHASH_HAVAL192
48ok
49
50MHASH_HAVAL224
51ok
52
53MHASH_HAVAL160
54ok
55
56MHASH_RIPEMD160
57ok
58
59MHASH_GOST
60ok
61
62MHASH_TIGER
63ok
64
65MHASH_CRC32
66ok
67
68MHASH_CRC32B
69ok
70