1--TEST-- 2Hash: hash_file() function : basic functionality 3--FILE-- 4<?php 5 6echo "*** Testing hash_file() : basic functionality ***\n"; 7 8$file = __DIR__ . "hash_file.txt"; 9/* Creating a temporary file file */ 10if (($fp = fopen( $file, "w+")) == FALSE) { 11 echo "Cannot create file ($file)"; 12 exit; 13} 14 15/* Writing into file */ 16$content = "This is a sample string used to test the hash_file function with various hashing algorithms"; 17if (is_writable($file)) { 18 if (fwrite($fp, $content) === FALSE) { 19 echo "Cannot write to file ($file)"; 20 exit; 21 } 22} 23 24// close the file 25fclose($fp); 26 27echo "adler32: " . hash_file('adler32', $file) . "\n"; 28echo "crc32: " . hash_file('crc32', $file) . "\n"; 29echo "gost: " . hash_file('gost', $file). "\n"; 30echo "haval128,3: " . hash_file('haval128,3', $file). "\n"; 31echo "md2: " . hash_file('md2', $file). "\n"; 32echo "md4: " . hash_file('md4', $file). "\n"; 33echo "md5: " . hash_file('md5', $file). "\n"; 34echo "ripemd128: " . hash_file('ripemd128', $file). "\n"; 35echo "ripemd160: " . hash_file('ripemd160', $file). "\n"; 36echo "ripemd256: " . hash_file('ripemd256', $file). "\n"; 37echo "ripemd320: " . hash_file('ripemd320', $file). "\n"; 38echo "sha1: " . hash_file('sha1', $file). "\n"; 39echo "sha256: " . hash_file('sha256', $file). "\n"; 40echo "sha384: " . hash_file('sha384', $file). "\n"; 41echo "sha512: " . hash_file('sha512', $file). "\n"; 42echo "snefru: " . hash_file('snefru', $file). "\n"; 43echo "tiger192,3: " . hash_file('tiger192,3', $file). "\n"; 44echo "whirlpool: " . hash_file('whirlpool', $file). "\n"; 45echo "murmur3a: " . hash_file('murmur3a', $file). "\n"; 46echo "murmur3a: " . hash_file('murmur3a', $file, false, ['seed' => 1234]). "\n"; 47echo "murmur3c: " . hash_file('murmur3c', $file). "\n"; 48echo "murmur3c: " . hash_file('murmur3c', $file, false, ['seed' => 1234]). "\n"; 49echo "murmur3f: " . hash_file('murmur3f', $file). "\n"; 50echo "murmur3f: " . hash_file('murmur3f', $file, false, ['seed' => 1234]). "\n"; 51 52echo "adler32(raw): " . bin2hex(hash_file('adler32', $file, TRUE)) . "\n"; 53echo "md5(raw): " . bin2hex(hash_file('md5', $file, TRUE)). "\n"; 54echo "sha256(raw): " . bin2hex(hash_file('sha256', $file, TRUE)). "\n"; 55 56unlink($file); 57 58?> 59--EXPECT-- 60*** Testing hash_file() : basic functionality *** 61adler32: ff87222e 62crc32: 61664d33 63gost: d9e65f0c0c2ef944e4f8a01f4a46365c4f33a2853756878182a7f03e1490a4cd 64haval128,3: c25962b13383c3ed9f13817c8f2ae7d6 65md2: 70f791c0d8fa9edd7d08e32fcba8c354 66md4: a9d034b16bb290c57a645afd6f14cd3b 67md5: 704bf818448f5bbb94061332d2c889aa 68ripemd128: d02a5f320a11c54c7d51f933b0bd8471 69ripemd160: 3ff296ca6314313af3ed0437c8fc0ebbd3242d3b 70ripemd256: 0edd779587c11cf32781111b264251eb37529832fb207121cd45dd95002e48a8 71ripemd320: bf162fa2ff20491b3016c5d8190f8ee47d7dcda8c38eaf6779349a243a029d275eec9adf16ec1b35 72sha1: 8529b266611e3bd0d208fd9614653c2a8f23d0fe 73sha256: a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245 74sha384: a35d875ed96d94b6452acad910f97978200faa2398d8a0e6b9cffa33704c3809e3d2e5b0d63700d8f32a0716e7d2d528 75sha512: 1f42adaf938fbf136e381b164bae5f984c7f9fe60c82728bd889c14f187c7d63e81a0305a1731c7e0a8f3ed9fd2ec92a3833a93502bdf269532601f0b8e2bab0 76snefru: d414b2345d3e7fa1a31c044cf334bfc1fec24d89e464411998d579d24663895f 77tiger192,3: 7acf4ebea075fac6fc8ea0e2b4af3cfa71b9460e4c53403a 78whirlpool: 4248b149e000477269a4a5f1a84d97cfc3d0199b7aaf505913e6f010a6f83276029d11a9ad545374bc710eb59c7d958985023ab886ffa9ec9a23852844c764ec 79murmur3a: bc6554c8 80murmur3a: 432e4379 81murmur3c: 8779de509ffc06fb27bcf5fc861504d6 82murmur3c: b43afac65c38a617323020432c170005 83murmur3f: 2b84cd546b2f18a9ab6f893194224afd 84murmur3f: 6cc7716646664d6a83d68cb6563ac38e 85adler32(raw): ff87222e 86md5(raw): 704bf818448f5bbb94061332d2c889aa 87sha256(raw): a0f5702fa5d3670b80033d668e8732b70550392abb53841355447f8bb0f72245 88