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