php-src/ext/hash/tests/hash_update_stream_basic_001.phpt
Nikita Popov 7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00

32 lines
702 B
PHP

--TEST--
Ensure hash_update_stream() always returns the same hash when $length = 0
--CREDITS--
Symeon Charalabides <symeon@systasis.com> - @phpdublin
--EXTENSIONS--
openssl
--FILE--
<?php
for ($j=0; $j<3; $j++)
{
// Create pseudo-random hash
$bytes = openssl_random_pseudo_bytes(15, $cstrong);
$hash = sha1(bin2hex($bytes));
// Create temp file with hash
$fp = tmpfile();
fwrite($fp, $hash);
rewind($fp);
// Stream it with 0 length and output hash
$ctx = hash_init('md5');
hash_update_stream($ctx, $fp, 0);
echo hash_final($ctx) . "\n";
}
?>
--EXPECT--
d41d8cd98f00b204e9800998ecf8427e
d41d8cd98f00b204e9800998ecf8427e
d41d8cd98f00b204e9800998ecf8427e