IP : 3.15.21.215Hostname : host45.registrar-servers.comKernel : Linux host45.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64Disable Function : None :) OS : Linux
PATH:
/
home/
../
var/
softaculous/
whmcs83/
./
../
./
pmwiki/
../
minibb/
../
lime/
sha256.php/
/
<?php
/******************************************************************************* * * SHA256 static class for PHP4 * implemented by feyd _at_ devnetwork .dot. net * specification from http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf * * ? Copyright 2005 Developer's Network. All rights reserved. * This is licensed under the Lesser General Public License (LGPL) * * Thanks to CertainKey Inc. for providing some example outputs in Javascript * *----- Version 1.0.1 ---------------------------------------------------------- * * Syntax: * string SHA256::hash( string message[, string format ]) * * Description: * SHA256::hash() is a static function that must be called with `message` * and optionally `format`. Possible values for `format` are: * 'bin' binary string output * 'hex' default; hexidecimal string output (lower case) * * Failures return FALSE. * * Usage: * $hash = SHA256::hash('string to hash'); * ******************************************************************************/
// hashing class state and storage object. Abstract base class only. class hashData { // final hash var $hash = null; }
// hashing class. Abstract base class only. class hash { // The base modes are: // 'bin' - binary output (most compact) // 'bit' - bit output (largest) // 'oct' - octal output (medium-large) // 'hex' - hexidecimal (default, medium)
// perform a hash on a string function hash($str, $mode = 'hex') { trigger_error('hash::hash() NOT IMPLEMENTED', E_USER_WARNING); return false; }
// chop the resultant hash into $length byte chunks function hashChunk($str, $length, $mode = 'hex') { trigger_error('hash::hashChunk() NOT IMPLEMENTED', E_USER_WARNING); return false; }
// perform a hash on a file function hashFile($filename, $mode = 'hex') { trigger_error('hash::hashFile() NOT IMPLEMENTED', E_USER_WARNING); return false; }
// chop the resultant hash into $length byte chunks function hashChunkFile($filename, $length, $mode = 'hex') { trigger_error('hash::hashChunkFile() NOT IMPLEMENTED', E_USER_WARNING); return false; } }
// ------------
class SHA256Data extends hashData { // buffer var $buf = array();
// padded data var $chunks = null;
function SHA256Data($str) { $M = strlen($str); // number of bytes $L1 = ($M >> 28) & 0x0000000F; // top order bits $L2 = $M << 3; // number of bits $l = pack('N*', $L1, $L2);
// 64 = 64 bits needed for the size mark. 1 = the 1 bit added to the // end. 511 = 511 bits to get the number to be at least large enough // to require one block. 512 is the block size. $k = $L2 + 64 + 1 + 511; $k -= $k % 512 + $L2 + 64 + 1; $k >>= 3; // convert to byte count
$str .= chr(0x80) . str_repeat(chr(0), $k) . $l;
assert('strlen($str) % 64 == 0');
// break the binary string into 512-bit blocks preg_match_all( '#.{64}#', $str, $this->chunks ); $this->chunks = $this->chunks[0];
$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', );