'; $test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'); foreach($test as $str) { echo 'Testing ' . var_export($str,true) . "\n"; list($s1,$s2) = explode(' ', microtime()); for($x = 0; $x < $it; $x++) $data = new SHA256Data($str); $data =& $data; list($e1,$e2) = explode(' ', microtime()); echo hexerize($data->chunks); echo hexerize($data->hash); echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n"; } echo '
'; $test = array('abc','abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'); foreach($test as $str) { echo 'Testing ' . var_export($str,true) . "\n"; list($s1,$s2) = explode(' ', microtime()); for($x = 0; $x < $it; $x++) $o = SHA256::hash($str); list($e1,$e2) = explode(' ', microtime()); echo $o; echo 'processing took ' . (($e2 - $s2 + $e1 - $s1) / $it) . ' seconds.' . "\n\n\n"; } echo '
'; echo SHA256::sum(1,2,3,4,5,6,7,8,9,10); echo '
' . "\n"; $test = array( ''=>'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', 'abc'=>'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', 'message digest'=>'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650', 'secure hash algorithm'=>'f30ceb2bb2829e79e4ca9753d35a8ecc00262d164cc077080295381cbd643f0d', 'SHA256 is considered to be safe'=>'6819d915c73f4d1e77e4e1b52d1fa0f9cf9beaead3939f15874bd988e2a23630', 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'=>'248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1', 'For this sample, this 63-byte string will be used as input data'=>'f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342', 'This is exactly 64 bytes long, not counting the terminating byte'=>'ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8', ); foreach($test as $str => $hash) { echo 'Testing ' . var_export($str,true) . "\n"; echo 'Start time: ' . date('Y-m-d H:i:s') . "\n"; if($it > 1) { list($s1,$s2) = explode(' ', microtime()); $o = SHA256::hash($str); list($e1,$e2) = explode(' ', microtime()); echo 'estimated time to perform test: ' . (($e2 - $s2 + $e1 - $s1) * $it) . ' seconds for ' . $it . ' iterations.' . "\n"; } $t = 0; for($x = 0; $x < $it; $x++) { list($s1,$s2) = explode(' ', microtime()); $o = SHA256::hash($str); list($e1,$e2) = explode(' ', microtime()); $t += $e2 - $s2 + $e1 - $s1; } echo var_export($o,true) . ' == ' . var_export($hash,true) . ' ' . (strcasecmp($o,$hash)==0 ? 'PASSED' : 'FAILED') . "\n"; echo 'processing took ' . ($t / $it) . ' seconds.' . "\n\n\n"; } echo '