summaryrefslogtreecommitdiff
path: root/ext/hash/tests/hash_hmac_error.phpt
blob: 1ed3e54127416df7f4e1d5d84458b4bc3606bf97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--TEST--
Hash: hash_hmac() function : basic functionality
--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 invalid hash algorithm --\n";
var_dump(hash_hmac('foo', $data, $key));

echo "\n-- Testing hash_hmac() function with non-cryptographic hash algorithm --\n";
var_dump(hash_hmac('crc32', $data, $key));

?>
===Done===
--EXPECTF--
*** Testing hash_hmac() : error conditions ***

-- Testing hash_hmac() function with invalid hash algorithm --

Warning: hash_hmac(): Unknown hashing algorithm: foo in %s on line %d
bool(false)

-- Testing hash_hmac() function with non-cryptographic hash algorithm --

Warning: hash_hmac(): Non-cryptographic hashing algorithm: crc32 in %s on line %d
bool(false)
===Done===