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