xref: /PHP-7.3/ext/hash/tests/mhash_001.phpt (revision 260e7770)
1--TEST--
2mhash() test
3--SKIPIF--
4<?php
5	include "skip_mhash.inc";
6?>
7--FILE--
8<?php
9
10$supported_hash_al = array(
11"MHASH_MD5"       => "2d9bdb91f94e96d9c4e2ae532acc936a",
12"MHASH_SHA1"      => "2f9341e55a9083edf5497bf83ba3db812a7de0a3",
13"MHASH_HAVAL256"  => "b255feff01ad641b27358dc7909bc695a1fca53bddfdfaf19020b275928793af",
14"MHASH_HAVAL192"  => "4ce837de481e1e30092ab2c610057094c988dfd7db1e01cd",
15"MHASH_HAVAL224"  => "5362d1856752bf2c139bb2d6fdd772b9c515c8ce5ec82695264b85e1",
16"MHASH_HAVAL160"  => "c6b36f87750b18576981bc17b4f22271947bf9cb",
17"MHASH_RIPEMD160" => "6c47435aa1d359c4b7c6af46349f0c3e1258583d",
18"MHASH_GOST"      => "101b0a2552cebdf5137cadf15147f21e55b6432935bb9c2c03c7e28d188b2d9e",
19"MHASH_TIGER"     => "953ac3799a01b9fdeb91aeab97207e67395cbb54300be00d",
20"MHASH_CRC32"     => "83041db8",
21"MHASH_CRC32B"    => "df5ab7a4"
22);
23
24$data = "This is the test of the mhash extension...";
25
26foreach ($supported_hash_al as $hash=>$wanted) {
27	$result = mhash(constant($hash), $data);
28	if (bin2hex($result)==$wanted) {
29		echo "$hash\nok\n";
30	} else {
31		echo "$hash: ";
32		var_dump($wanted);
33		echo "$hash: ";
34		var_dump(bin2hex($result));
35	}
36	echo "\n";
37}
38?>
39--EXPECT--
40MHASH_MD5
41ok
42
43MHASH_SHA1
44ok
45
46MHASH_HAVAL256
47ok
48
49MHASH_HAVAL192
50ok
51
52MHASH_HAVAL224
53ok
54
55MHASH_HAVAL160
56ok
57
58MHASH_RIPEMD160
59ok
60
61MHASH_GOST
62ok
63
64MHASH_TIGER
65ok
66
67MHASH_CRC32
68ok
69
70MHASH_CRC32B
71ok
72