mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
New hash extension tests. Tested on Windows, Linux and Linux 64-bit
This commit is contained in:
parent
697931b765
commit
84cd47bdb5
107
ext/hash/tests/hash_algos.phpt
Normal file
107
ext/hash/tests/hash_algos.phpt
Normal file
@ -0,0 +1,107 @@
|
||||
--TEST--
|
||||
Test hash_algos() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : array hash_algos (void)
|
||||
* Description: Return a list of registered hashing algorithms
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing hash_algos() : basic functionality ***\n";
|
||||
var_dump(hash_algos());
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_algos() : basic functionality ***
|
||||
array(42) {
|
||||
[0]=>
|
||||
unicode(3) "md2"
|
||||
[1]=>
|
||||
unicode(3) "md4"
|
||||
[2]=>
|
||||
unicode(3) "md5"
|
||||
[3]=>
|
||||
unicode(4) "sha1"
|
||||
[4]=>
|
||||
unicode(6) "sha224"
|
||||
[5]=>
|
||||
unicode(6) "sha256"
|
||||
[6]=>
|
||||
unicode(6) "sha384"
|
||||
[7]=>
|
||||
unicode(6) "sha512"
|
||||
[8]=>
|
||||
unicode(9) "ripemd128"
|
||||
[9]=>
|
||||
unicode(9) "ripemd160"
|
||||
[10]=>
|
||||
unicode(9) "ripemd256"
|
||||
[11]=>
|
||||
unicode(9) "ripemd320"
|
||||
[12]=>
|
||||
unicode(9) "whirlpool"
|
||||
[13]=>
|
||||
unicode(10) "tiger128,3"
|
||||
[14]=>
|
||||
unicode(10) "tiger160,3"
|
||||
[15]=>
|
||||
unicode(10) "tiger192,3"
|
||||
[16]=>
|
||||
unicode(10) "tiger128,4"
|
||||
[17]=>
|
||||
unicode(10) "tiger160,4"
|
||||
[18]=>
|
||||
unicode(10) "tiger192,4"
|
||||
[19]=>
|
||||
unicode(6) "snefru"
|
||||
[20]=>
|
||||
unicode(9) "snefru256"
|
||||
[21]=>
|
||||
unicode(4) "gost"
|
||||
[22]=>
|
||||
unicode(7) "adler32"
|
||||
[23]=>
|
||||
unicode(5) "crc32"
|
||||
[24]=>
|
||||
unicode(6) "crc32b"
|
||||
[25]=>
|
||||
unicode(7) "salsa10"
|
||||
[26]=>
|
||||
unicode(7) "salsa20"
|
||||
[27]=>
|
||||
unicode(10) "haval128,3"
|
||||
[28]=>
|
||||
unicode(10) "haval160,3"
|
||||
[29]=>
|
||||
unicode(10) "haval192,3"
|
||||
[30]=>
|
||||
unicode(10) "haval224,3"
|
||||
[31]=>
|
||||
unicode(10) "haval256,3"
|
||||
[32]=>
|
||||
unicode(10) "haval128,4"
|
||||
[33]=>
|
||||
unicode(10) "haval160,4"
|
||||
[34]=>
|
||||
unicode(10) "haval192,4"
|
||||
[35]=>
|
||||
unicode(10) "haval224,4"
|
||||
[36]=>
|
||||
unicode(10) "haval256,4"
|
||||
[37]=>
|
||||
unicode(10) "haval128,5"
|
||||
[38]=>
|
||||
unicode(10) "haval160,5"
|
||||
[39]=>
|
||||
unicode(10) "haval192,5"
|
||||
[40]=>
|
||||
unicode(10) "haval224,5"
|
||||
[41]=>
|
||||
unicode(10) "haval256,5"
|
||||
}
|
||||
===Done===
|
48
ext/hash/tests/hash_error.phpt
Normal file
48
ext/hash/tests/hash_error.phpt
Normal file
@ -0,0 +1,48 @@
|
||||
--TEST--
|
||||
Test hash() function : error conditions
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string hash ( string $algo , string $data [, bool $raw_output ] )
|
||||
* Description: Generate a hash value (message digest)
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
echo "*** Testing hash() : error conditions ***\n";
|
||||
|
||||
echo "\n-- Testing hash() function with less than expected no. of arguments --\n";
|
||||
var_dump(hash());
|
||||
var_dump(hash('adler32'));
|
||||
|
||||
echo "\n-- Testing hash() function with more than expected no. of arguments --\n";
|
||||
$extra_arg= 10;
|
||||
var_dump(hash('adler32', '', false, $extra_arg));
|
||||
|
||||
echo "\n-- Testing hash() function with invalid hash algorithm --\n";
|
||||
var_dump(hash('foo', ''));
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash() : error conditions ***
|
||||
|
||||
-- Testing hash() function with less than expected no. of arguments --
|
||||
|
||||
Warning: hash() expects at least 2 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: hash() expects at least 2 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing hash() function with more than expected no. of arguments --
|
||||
|
||||
Warning: hash() expects at most 3 parameters, 4 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing hash() function with invalid hash algorithm --
|
||||
|
||||
Warning: hash(): Unknown hashing algorithm: foo in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
85
ext/hash/tests/hash_file_basic1.phpt
Normal file
85
ext/hash/tests/hash_file_basic1.phpt
Normal file
@ -0,0 +1,85 @@
|
||||
--TEST--
|
||||
Test hash_file() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string hash_file ( string algo, string filename [, bool raw_output] )
|
||||
* Description: Generate a hash value using the contents of a given file
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing hash_file() : basic functionality ***\n";
|
||||
|
||||
$file = dirname(__FILE__) . "hash_file.txt";
|
||||
/* Creating a temporary file file */
|
||||
if (($fp = fopen( $file, "w+")) == FALSE) {
|
||||
echo "Cannot create file ($file)";
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Writing into file */
|
||||
$content = b"This is a sample string used to test the hash_file function with various hashing algorithms";
|
||||
if (is_writable($file)) {
|
||||
if (fwrite($fp, $content) === FALSE) {
|
||||
echo "Cannot write to file ($file)";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// close the file
|
||||
fclose($fp);
|
||||
|
||||
echo "adler32: " . hash_file('adler32', $file) . "\n";
|
||||
echo "crc32: " . hash_file('crc32', $file) . "\n";
|
||||
echo "gost: " . hash_file('gost', $file). "\n";
|
||||
echo "haval128,3: " . hash_file('haval128,3', $file). "\n";
|
||||
echo "md2: " . hash_file('md2', $file). "\n";
|
||||
echo "md4: " . hash_file('md4', $file). "\n";
|
||||
echo "md5: " . hash_file('md5', $file). "\n";
|
||||
echo "ripemd128: " . hash_file('ripemd128', $file). "\n";
|
||||
echo "ripemd160: " . hash_file('ripemd160', $file). "\n";
|
||||
echo "ripemd256: " . hash_file('ripemd256', $file). "\n";
|
||||
echo "ripemd320: " . hash_file('ripemd320', $file). "\n";
|
||||
echo "sha1: " . hash_file('sha1', $file). "\n";
|
||||
echo "sha256: " . hash_file('sha256', $file). "\n";
|
||||
echo "sha384: " . hash_file('sha384', $file). "\n";
|
||||
echo "sha512: " . hash_file('sha512', $file). "\n";
|
||||
echo "snefru: " . hash_file('snefru', $file). "\n";
|
||||
echo "tiger192,3: " . hash_file('tiger192,3', $file). "\n";
|
||||
echo "whirlpool: " . hash_file('whirlpool', $file). "\n";
|
||||
|
||||
echo "adler32(raw): " . bin2hex(hash_file('adler32', $file, TRUE)) . "\n";
|
||||
echo "md5(raw): " . bin2hex(hash_file('md5', $file, TRUE)). "\n";
|
||||
echo "sha256(raw): " . bin2hex(hash_file('sha256', $file, TRUE)). "\n";
|
||||
|
||||
unlink($file);
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_file() : basic functionality ***
|
||||
adler32: 2e2287ff
|
||||
crc32: 61664d33
|
||||
gost: d9e65f0c0c2ef944e4f8a01f4a46365c4f33a2853756878182a7f03e1490a4cd
|
||||
haval128,3: 8bb81269aca8b7f87829020d76a4e841
|
||||
md2: 70f791c0d8fa9edd7d08e32fcba8c354
|
||||
md4: a9d034b16bb290c57a645afd6f14cd3b
|
||||
md5: 704bf818448f5bbb94061332d2c889aa
|
||||
ripemd128: d02a5f320a11c54c7d51f933b0bd8471
|
||||
ripemd160: 3ff296ca6314313af3ed0437c8fc0ebbd3242d3b
|
||||
ripemd256: 0edd779587c11cf32781111b264251eb37529832fb207121cd45dd95002e48a8
|
||||
ripemd320: bf162fa2ff20491b3016c5d8190f8ee47d7dcda8c38eaf6779349a243a029d275eec9adf16ec1b35
|
||||
sha1: 8529b266611e3bd0d208fd9614653c2a8f23d0fe
|
||||
sha256: a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245
|
||||
sha384: a35d875ed96d94b6452acad910f97978200faa2398d8a0e6b9cffa33704c3809e3d2e5b0d63700d8f32a0716e7d2d528
|
||||
sha512: 1f42adaf938fbf136e381b164bae5f984c7f9fe60c82728bd889c14f187c7d63e81a0305a1731c7e0a8f3ed9fd2ec92a3833a93502bdf269532601f0b8e2bab0
|
||||
snefru: d414b2345d3e7fa1a31c044cf334bfc1fec24d89e464411998d579d24663895f
|
||||
tiger192,3: c6fa75a0be4ecf7afa3cafb4e2a08efc3a40534c0e46b971
|
||||
whirlpool: 4248b149e000477269a4a5f1a84d97cfc3d0199b7aaf505913e6f010a6f83276029d11a9ad545374bc710eb59c7d958985023ab886ffa9ec9a23852844c764ec
|
||||
adler32(raw): 2e2287ff
|
||||
md5(raw): 704bf818448f5bbb94061332d2c889aa
|
||||
sha256(raw): a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245
|
||||
===Done===
|
66
ext/hash/tests/hash_hmac_basic.phpt
Normal file
66
ext/hash/tests/hash_hmac_basic.phpt
Normal file
@ -0,0 +1,66 @@
|
||||
--TEST--
|
||||
Test hash_file() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string hash_hmac ( string $algo , string $data , string $key [, bool $raw_output ] )
|
||||
* Description: Generate a keyed hash value using the HMAC method
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing hash_hmac() : basic functionality ***\n";
|
||||
|
||||
$content = "This is a sample string used to test the hash_hmac function with various hashing algorithms";
|
||||
$key = 'secret';
|
||||
|
||||
echo "adler32: " . hash_hmac('adler32', $content, $key) . "\n";
|
||||
echo "crc32: " . hash_hmac('crc32', $content, $key) . "\n";
|
||||
echo "gost: " . hash_hmac('gost', $content, $key) . "\n";
|
||||
echo "haval128,3: " . hash_hmac('haval128,3', $content, $key) . "\n";
|
||||
echo "md2: " . hash_hmac('md2', $content, $key) . "\n";
|
||||
echo "md4: " . hash_hmac('md4', $content, $key) . "\n";
|
||||
echo "md5: " . hash_hmac('md5', $content, $key) . "\n";
|
||||
echo "ripemd128: " . hash_hmac('ripemd128', $content, $key) . "\n";
|
||||
echo "ripemd160: " . hash_hmac('ripemd160', $content, $key) . "\n";
|
||||
echo "ripemd256: " . hash_hmac('ripemd256', $content, $key) . "\n";
|
||||
echo "ripemd320: " . hash_hmac('ripemd320', $content, $key) . "\n";
|
||||
echo "sha1: " . hash_hmac('sha1', $content, $key) . "\n";
|
||||
echo "sha256: " . hash_hmac('sha256', $content, $key) . "\n";
|
||||
echo "sha384: " . hash_hmac('sha384', $content, $key) . "\n";
|
||||
echo "sha512: " . hash_hmac('sha512', $content, $key) . "\n";
|
||||
echo "snefru: " . hash_hmac('snefru', $content, $key) . "\n";
|
||||
echo "tiger192,3: " . hash_hmac('tiger192,3', $content, $key) . "\n";
|
||||
echo "whirlpool: " . hash_hmac('whirlpool', $content, $key) . "\n";
|
||||
echo "adler32(raw): " . bin2hex(hash_hmac('adler32', $content, $key, TRUE)) . "\n";
|
||||
echo "md5(raw): " . bin2hex(hash_hmac('md5', $content, $key, TRUE)) . "\n";
|
||||
echo "sha256(raw): " . bin2hex(hash_hmac('sha256', $content, $key, TRUE)) . "\n";
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_hmac() : basic functionality ***
|
||||
adler32: 9e033311
|
||||
crc32: 96859101
|
||||
gost: a4a3c80bdf3f8665bf07376a34dc9c1b11af7c813f4928f62e39f0c0dc564dad
|
||||
haval128,3: 82cd0f4bd36729b5c80c33efa8c13ac5
|
||||
md2: 6d111dab563025e4cb5f4425c991fa12
|
||||
md4: 10cdbfe843000c623f8b8da0d5d20b0b
|
||||
md5: 2a632783e2812cf23de100d7d6a463ae
|
||||
ripemd128: 26c2f694a65b1928b668cf55f65529b4
|
||||
ripemd160: 4b3433ba596ec39692bb7ce760a9ee5fb818113f
|
||||
ripemd256: 4e4e5ec19322895a727f272dfe68f87bc1af66cc6ce27c6c1360a5ee78a14b30
|
||||
ripemd320: f10a8ff82e828b92a5ff0a02fc9032bc61352d0d824821fc42f7e09cf5b5f41ee59fd33a730d7469
|
||||
sha1: 5bfdb62b97e2c987405463e9f7c193139c0e1fd0
|
||||
sha256: 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838
|
||||
sha384: b781415b856744834e532b9899e1aa0bec5a82cf09a838f0a833470468e2a42648a52428cfd9012385d04de5cd9bd122
|
||||
sha512: 7de05636b18e2b0ca3427e03f53074af3a48a7b9df226daba4f22324c570638e7d7b26430e214799c9ce0db5ee88dad3292ca0f38bf99b8eaebed59b3a9c140a
|
||||
snefru: 67af483046f9cf16fe19f9087929ccfc6ad176ade3290b4d33f43e0ddb07e711
|
||||
tiger192,3: 82779797cdc439e886884953ba21fa38e35679041e95ee27
|
||||
whirlpool: 4a0f1582b21b7aff59bfba7f9c29131c69741b2ce80acdc7d314040f3b768cf5a17e30b74cceb86fbc6b34b1692e0addd5bfd7cfc043d40c0621f1b97e26fa49
|
||||
adler32(raw): 9e033311
|
||||
md5(raw): 2a632783e2812cf23de100d7d6a463ae
|
||||
sha256(raw): 49bde3496b9510a17d0edd8a4b0ac70148e32a1d51e881ec76faa96534125838
|
||||
===Done===
|
54
ext/hash/tests/hash_hmac_error.phpt
Normal file
54
ext/hash/tests/hash_hmac_error.phpt
Normal file
@ -0,0 +1,54 @@
|
||||
--TEST--
|
||||
Test hash_hmac() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
/*
|
||||
* proto string hash_hmac ( string algo, string data, string key [, bool raw_output] )
|
||||
* Function is implemented in ext/hash/hash.c
|
||||
*/
|
||||
|
||||
echo "*** Testing hash_hmac() : error conditions ***\n";
|
||||
|
||||
$data = "This is a sample string used to test the hash_hmac function with various hashing algorithms";
|
||||
$key = 'secret';
|
||||
|
||||
echo "\n-- Testing hash_hmac() function with less than expected no. of arguments --\n";
|
||||
var_dump(hash_hmac());
|
||||
var_dump(hash_hmac('crc32'));
|
||||
var_dump(hash_hmac('crc32', $data));
|
||||
|
||||
echo "\n-- Testing hash_hmac() function with more than expected no. of arguments --\n";
|
||||
$extra_arg = 10;
|
||||
var_dump(hash_hmac('crc32', $data, $key, TRUE, $extra_arg));
|
||||
|
||||
echo "\n-- Testing hash_hmac() function with invalid hash algorithm --\n";
|
||||
var_dump(hash_hmac('foo', $data, $key));
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_hmac() : error conditions ***
|
||||
|
||||
-- Testing hash_hmac() function with less than expected no. of arguments --
|
||||
|
||||
Warning: hash_hmac() expects at least 3 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: hash_hmac() expects at least 3 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: hash_hmac() expects at least 3 parameters, 2 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing hash_hmac() function with more than expected no. of arguments --
|
||||
|
||||
Warning: hash_hmac() expects at most 4 parameters, 5 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing hash_hmac() function with invalid hash algorithm --
|
||||
|
||||
Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d
|
||||
bool(false)
|
||||
===Done===
|
101
ext/hash/tests/hash_hmac_file_basic.phpt
Normal file
101
ext/hash/tests/hash_hmac_file_basic.phpt
Normal file
@ -0,0 +1,101 @@
|
||||
--TEST--
|
||||
Test hash_hmac_file() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
||||
/* Prototype : string hash_hmac_file ( string algo, string filename, string key [, bool raw_output] )
|
||||
* Description: Generate a keyed hash value using the HMAC method and the contents of a given file
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing hash_hmac_file() : basic functionality ***\n";
|
||||
|
||||
$file = dirname(__FILE__) . "hash_hmac_file.txt";
|
||||
/* Creating a temporary file file */
|
||||
if (($fp = fopen( $file, "w+")) == FALSE) {
|
||||
echo "Cannot create file ($file)";
|
||||
exit;
|
||||
}
|
||||
|
||||
/* Writing into file */
|
||||
$content = b"This is a sample string used to test the hash_hmac_file function with various hashing algorithms";
|
||||
if (is_writable($file)) {
|
||||
if (fwrite($fp, $content) === FALSE) {
|
||||
echo "Cannot write to file ($file)";
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// close the files
|
||||
fclose($fp);
|
||||
|
||||
$key = 'secret';
|
||||
|
||||
|
||||
echo "adler32: " . hash_hmac_file('adler32', $file, $key) . "\n";
|
||||
echo "crc32: " . hash_hmac_file('crc32', $file, $key) . "\n";
|
||||
echo "gost: " . hash_hmac_file('gost', $file, $key) . "\n";
|
||||
echo "haval128,3: " . hash_hmac_file('haval128,3', $file, $key) . "\n";
|
||||
echo "md2: " . hash_hmac_file('md2', $file, $key) . "\n";
|
||||
echo "md4: " . hash_hmac_file('md4', $file, $key) . "\n";
|
||||
echo "md5: " . hash_hmac_file('md5', $file, $key) . "\n";
|
||||
echo "ripemd128: " . hash_hmac_file('ripemd128', $file, $key) . "\n";
|
||||
echo "ripemd160: " . hash_hmac_file('ripemd160', $file, $key) . "\n";
|
||||
echo "ripemd256: " . hash_hmac_file('ripemd256', $file, $key) . "\n";
|
||||
echo "ripemd320: " . hash_hmac_file('ripemd320', $file, $key) . "\n";
|
||||
echo "sha1: " . hash_hmac_file('sha1', $file, $key) . "\n";
|
||||
echo "sha256: " . hash_hmac_file('sha256', $file, $key) . "\n";
|
||||
echo "sha384: " . hash_hmac_file('sha384', $file, $key) . "\n";
|
||||
echo "sha512: " . hash_hmac_file('sha512', $file, $key) . "\n";
|
||||
echo "snefru: " . hash_hmac_file('snefru', $file, $key) . "\n";
|
||||
echo "tiger192,3: " . hash_hmac_file('tiger192,3', $file, $key) . "\n";
|
||||
echo "whirlpool: " . hash_hmac_file('whirlpool', $file, $key) . "\n";
|
||||
|
||||
echo "adler32(raw): " . bin2hex(hash_hmac_file('adler32', $file, $key, TRUE)) . "\n";
|
||||
echo "md5(raw): " . bin2hex(hash_hmac_file('md5', $file, $key, TRUE)). "\n";
|
||||
echo "sha256(raw): " . bin2hex(hash_hmac_file('sha256', $file, $key, TRUE)). "\n";
|
||||
|
||||
echo "Error cases:\n";
|
||||
hash_hmac_file();
|
||||
hash_hmac_file('foo', $file);
|
||||
hash_hmac_file('foo', $file, $key, TRUE, 10);
|
||||
|
||||
unlink($file);
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash_hmac_file() : basic functionality ***
|
||||
adler32: 9f037811
|
||||
crc32: f2a60b9c
|
||||
gost: 94c39a40d5db852a8dc3d24e37eebf2d53e3d711457c59cd02b614f792a9d918
|
||||
haval128,3: e8fcff647f1a675acb429130fb94a17e
|
||||
md2: a685475e600314bb549ab4f33c3b27cb
|
||||
md4: cbc6bff781f48f57378d3effa27553e4
|
||||
md5: 8bddf39dd1c566c27acc7fa85ec36acf
|
||||
ripemd128: 03269b76bf61d508c50f038cbe9ba691
|
||||
ripemd160: 94652211292268d97eb63344a3a05d3009f9d2d3
|
||||
ripemd256: b6ab414cc1630e1e474fefa41976d252f38ca7cf401552774e71736165e512e7
|
||||
ripemd320: 71271a649265740eed4b9931417f979fd81eba6288f4e08ff2997bc3dd6858da054d53a9f1fffe8c
|
||||
sha1: 7f338d17b72371091abd28f451bc8d1f3a9eb3b6
|
||||
sha256: 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40
|
||||
sha384: 364fdc45a4c742763366ab5d3d1c17c24057e6c3b641607a36d969f00c88da25b19c8b88c8632411e3a0a02397f88aca
|
||||
sha512: d460aabdf0353655059ed0d408efa91f19c4cda46acc2a4e0adf4764b06951c899fbb2ed41519db78b58ff7be17b1b2910aebe674a56861b232143571b35c83f
|
||||
snefru: 7b79787e1c1d926b6cc98327f05c5d04ba6227ab51c1398661861196016ef34c
|
||||
tiger192,3: 5577f21e2af269fff41e023db30e2b01bfd8b8f669177929
|
||||
whirlpool: 37a0fbb90547690d5e5e11c046f6654ffdb7bab15e16d9d79c7d85765cc4bdcbfd9df8db7a3ce9558f3f244fead00ca29cf05297f75596555195a0683f15d69f
|
||||
adler32(raw): 9f037811
|
||||
md5(raw): 8bddf39dd1c566c27acc7fa85ec36acf
|
||||
sha256(raw): 9135286ca4c84dec711e4b831f6cd39e672e5ff93d011321274eb76733cc1e40
|
||||
Error cases:
|
||||
|
||||
Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
|
||||
|
||||
Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
|
||||
|
||||
Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
|
||||
===Done===
|
54
ext/hash/tests/hash_hmac_file_error.phpt
Normal file
54
ext/hash/tests/hash_hmac_file_error.phpt
Normal file
@ -0,0 +1,54 @@
|
||||
--TEST--
|
||||
Test hash_hmac_file() function : basic functionality
|
||||
--SKIPIF--
|
||||
<?php extension_loaded('hash') or die('skip: hash extension not loaded.'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
/* Prototype : string hash_hmac_file ( string algo, string filename, string key [, bool raw_output] )
|
||||
* Description: Generate a keyed hash value using the HMAC method and the contents of a given file
|
||||
* Source code: ext/hash/hash.c
|
||||
* Alias to functions:
|
||||
*/
|
||||
|
||||
echo "*** Testing hash() : error conditions ***\n";
|
||||
|
||||
$file = dirname(__FILE__) . "hash_file.txt";
|
||||
$key = 'secret';
|
||||
|
||||
echo "\n-- Testing hash_hmac_file() function with less than expected no. of arguments --\n";
|
||||
var_dump(hash_hmac_file());
|
||||
var_dump(hash_hmac_file('crc32'));
|
||||
var_dump(hash_hmac_file('crc32', $file));
|
||||
|
||||
echo "\n-- Testing hash_hmac_file() function with more than expected no. of arguments --\n";
|
||||
$extra_arg = 10;
|
||||
hash_hmac_file('crc32', $file, $key, TRUE, $extra_arg);
|
||||
|
||||
echo "\n-- Testing hash_hmac_file() function with invalid hash algorithm --\n";
|
||||
hash_hmac_file('foo', $file, $key, TRUE);
|
||||
|
||||
?>
|
||||
===Done===
|
||||
--EXPECTF--
|
||||
*** Testing hash() : error conditions ***
|
||||
|
||||
-- Testing hash_hmac_file() function with less than expected no. of arguments --
|
||||
|
||||
Warning: hash_hmac_file() expects at least 3 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: hash_hmac_file() expects at least 3 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: hash_hmac_file() expects at least 3 parameters, 2 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing hash_hmac_file() function with more than expected no. of arguments --
|
||||
|
||||
Warning: hash_hmac_file() expects at most 4 parameters, 5 given in %s on line %d
|
||||
|
||||
-- Testing hash_hmac_file() function with invalid hash algorithm --
|
||||
|
||||
Warning: hash_hmac_file(): Unknown hashing algorithm: foo in %s on line %d
|
||||
===Done===
|
Loading…
Reference in New Issue
Block a user