1
0
mirror of https://github.com/php/php-src.git synced 2026-03-30 12:13:02 +02:00
Files
archived-php-src/ext/hash/tests/hash_init_error.phpt
2019-08-29 16:09:29 +02:00

52 lines
1.2 KiB
PHP

--TEST--
Hash: hash_init() function - errors test
--FILE--
<?php
echo "*** Testing hash_init(): error conditions ***\n";
echo "\n-- Testing hash_init() function with unknown algorithms --\n";
try {
var_dump(hash_init('dummy'));
}
catch (\Error $e) {
echo $e->getMessage() . "\n";
}
echo "\n-- Testing hash_init() function with HASH_HMAC and non-cryptographic algorithms --\n";
try {
var_dump(hash_init('crc32', HASH_HMAC));
}
catch (\Error $e) {
echo $e->getMessage() . "\n";
}
echo "\n-- Testing hash_init() function with HASH_HMAC and no key --\n";
try {
var_dump(hash_init('md5', HASH_HMAC));
}
catch (\Error $e) {
echo $e->getMessage() . "\n";
}
try {
var_dump(hash_init('md5', HASH_HMAC, null));
}
catch (\Error $e) {
echo $e->getMessage() . "\n";
}
?>
--EXPECT--
*** Testing hash_init(): error conditions ***
-- Testing hash_init() function with unknown algorithms --
Unknown hashing algorithm: dummy
-- Testing hash_init() function with HASH_HMAC and non-cryptographic algorithms --
HMAC requested with a non-cryptographic hashing algorithm: crc32
-- Testing hash_init() function with HASH_HMAC and no key --
HMAC requested without a key
HMAC requested without a key