示例#1
-1
function testSHA3($outputSize = null)
{
    $testCases = array('', 'abc', 'The quick brown fox jumps over the lazy dog', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
    foreach ($testCases as $t) {
        if (isset($outputSize)) {
            echo sha3($t, $outputSize) . PHP_EOL;
        } else {
            echo sha3($t) . PHP_EOL;
        }
    }
}
示例#2
-1
文件: Sha3.php 项目: nirnanaaa/xlix
 public function encryptString($string, $salt)
 {
     $hashes_used_secondary = array("sha1", "sha256", "whirlpool", "adler32", "md5", "crc32", "snefru256", "salsa20", "sha512");
     $saltArray = unpack("N*", $salt);
     $saltcount = (string) $saltArray[1];
     $saltcount = substr($saltcount, 0, 3);
     $hash_use = $hashes_used_secondary[$saltcount[1] - 1];
     $hasharray = array();
     for ($count = 0; $count <= $saltcount * 2; $count++) {
         $hasharray[] = sha3($this->ascDec($string) * $count);
         if (null !== hash($hash_use, $salt)) {
             $hasharray[] = hash($hash_use, $salt);
         }
     }
     $reval = array("salt" => $salt, "hash" => sha3(implode("", $hasharray), 384));
     return $reval;
 }
示例#3
-1
 public function createSha3Salt()
 {
     $basesalt = base_convert(sha3(mktime(mt_rand(1, 24), mt_rand(1, 60), mt_rand(1, 60), mt_rand(1, 12), mt_rand(1, 7), mt_rand(1970, 2051)) + mt_getrandmax(), 384), 16, 10);
     $basesalt = $basesalt * 256;
     return sha3($basesalt, 256);
 }