Browse Source
Switched to a new parameter parsing API, which simplifies the code a great deal.
Switched to a new parameter parsing API, which simplifies the code a great deal.
Made error reporting use php_error_docref() Fixed a bug in mhash_keygen_s2k() that caused non \0 terminated data to be returned. Added tests of all mhash functions.experimental/threaded
5 changed files with 154 additions and 101 deletions
-
155ext/mhash/mhash.c
-
67ext/mhash/tests/001.phpt
-
28ext/mhash/tests/002.phpt
-
BINext/mhash/tests/003.phpt
-
5ext/mhash/tests/skip.inc
@ -0,0 +1,67 @@ |
|||
--TEST-- |
|||
mhash() test |
|||
--SKIPIF-- |
|||
<?php |
|||
include "skip.inc"; |
|||
?> |
|||
--FILE-- |
|||
<?php |
|||
|
|||
$supported_hash_al = array( |
|||
"MHASH_MD5", |
|||
"MHASH_SHA1", |
|||
"MHASH_HAVAL256", |
|||
"MHASH_HAVAL192", |
|||
"MHASH_HAVAL224", |
|||
"MHASH_HAVAL160", |
|||
"MHASH_RIPEMD160", |
|||
"MHASH_GOST", |
|||
"MHASH_TIGER", |
|||
"MHASH_CRC32", |
|||
"MHASH_CRC32B" |
|||
); |
|||
|
|||
$data = "This is the test of the mhash extension..."; |
|||
|
|||
foreach ($supported_hash_al as $hash) { |
|||
echo $hash . "\n"; |
|||
var_dump(mhash(constant($hash), $data)); |
|||
echo "\n"; |
|||
} |
|||
?> |
|||
--EXPECT-- |
|||
MHASH_MD5 |
|||
string(16) "-›Û‘ùN–ÙÄâ®S*Ì“j" |
|||
|
|||
MHASH_SHA1 |
|||
string(20) "/“AåZ�ƒíõI{ø;£Û�*}à£" |
|||
|
|||
MHASH_HAVAL256 |
|||
string(32) "²Uþÿd'5�Ç�›Æ•¡ü¥;Ýýúñ� ²u’‡“¯" |
|||
|
|||
MHASH_HAVAL192 |
|||
string(24) "Lè7ÞH0 *²Æp”Ɉß×ÛÍ" |
|||
|
|||
MHASH_HAVAL224 |
|||
string(28) "SbÑ…gR¿,›²Öý×r¹ÅÈÎ^È&•&K…á" |
|||
|
|||
MHASH_HAVAL160 |
|||
string(20) "Ƴo‡uWi�¼´ò"q”{ùË" |
|||
|
|||
MHASH_RIPEMD160 |
|||
string(20) "lGCZ¡ÓYķƯF4Ÿ>XX=" |
|||
|
|||
MHASH_GOST |
|||
string(32) " |
|||
%Rνõ|ñQGòU¶C)5»œ,Çâ�‹-ž" |
|||
|
|||
MHASH_TIGER |
|||
string(24) "•:Ãyš¹ýë‘®«— ~g9\»T0à |
|||
" |
|||
|
|||
MHASH_CRC32 |
|||
string(4) "ƒ¸" |
|||
|
|||
MHASH_CRC32B |
|||
string(4) "¤·Zß" |
|||
|
|||
@ -0,0 +1,28 @@ |
|||
--TEST-- |
|||
mhash_get_block_size() & mhash_get_hash_name() test |
|||
--SKIPIF-- |
|||
<?php |
|||
include "skip.inc"; |
|||
?> |
|||
--FILE-- |
|||
<?php |
|||
$hc = mhash_count() + 1; |
|||
|
|||
for ($i=0; $i<$hc; $i++) { |
|||
if (($hn = mhash_get_hash_name($i))) { |
|||
echo $hn . "\t->\t" . mhash_get_block_size($i) . "\n"; |
|||
} |
|||
} |
|||
?> |
|||
--EXPECT-- |
|||
CRC32 -> 4 |
|||
MD5 -> 16 |
|||
SHA1 -> 20 |
|||
HAVAL256 -> 32 |
|||
RIPEMD160 -> 20 |
|||
TIGER -> 24 |
|||
GOST -> 32 |
|||
CRC32B -> 4 |
|||
HAVAL224 -> 28 |
|||
HAVAL192 -> 24 |
|||
HAVAL160 -> 20 |
|||
@ -0,0 +1,5 @@ |
|||
<?php |
|||
if (!extension_loaded("mhash")) { |
|||
die("skip mhash extension is not avaliable"); |
|||
} |
|||
?> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue