xref: /PHP-7.4/ext/hash/tests/mhash_002.phpt (revision 782352c5)
1--TEST--
2MHash: mhash_get_block_size() & mhash_get_hash_name() test
3--SKIPIF--
4<?php if(!function_exists('mhash')) { die('skip mhash compatibility layer not available'); } ?>
5--FILE--
6<?php
7$supported_hash_al = array(
8"MD5"       => 16,
9"MD4"       => 16,
10"SHA1"      => 20,
11"SHA256"    => 32,
12"HAVAL256"  => 32,
13"HAVAL192"  => 24,
14"HAVAL224"  => 28,
15"HAVAL160"  => 20,
16"HAVAL128"  => 16,
17"RIPEMD160" => 20,
18"GOST"      => 32,
19"TIGER"     => 24,
20"TIGER160"  => 20,
21"TIGER128"  => 16,
22"CRC32"     => 4,
23"CRC32B"    => 4,
24"ADLER32"   => 4,
25"NA_XYZ"    => 0   /* verify that the algorithm works */
26);
27
28$hc = mhash_count() + 1;
29
30$known_hash_al = array();
31for ($i=0; $i < $hc; $i++) {
32	$known_hash_al[mhash_get_hash_name($i)] = $i;
33}
34
35foreach ($supported_hash_al as $name => $len) {
36	if (array_key_exists($name, $known_hash_al)) {
37		$len = mhash_get_block_size($known_hash_al[$name]);
38		echo "$name = $len\n";
39	} else {
40		echo "$name ? $len\n";
41	}
42}
43?>
44--EXPECTREGEX--
45MD5 . 16
46MD4 . 16
47SHA1 . 20
48SHA256 . 32
49HAVAL256 . 32
50HAVAL192 . 24
51HAVAL224 . 28
52HAVAL160 . 20
53HAVAL128 . 16
54RIPEMD160 . 20
55GOST . 32
56TIGER . 24
57TIGER160 . 20
58TIGER128 . 16
59CRC32 . 4
60CRC32B . 4
61ADLER32 . 4
62NA_XYZ . 0
63