ParagonIE\Halite\Util::raw_hash PHP Method

raw_hash() public static method

Returns raw binary.
public static raw_hash ( string $input, integer $length = Sodium\CRYPTO_GENERICHASH_BYTES ) : string
$input string
$length integer
return string
    public static function raw_hash(string $input, int $length = \Sodium\CRYPTO_GENERICHASH_BYTES) : string
    {
        return self::raw_keyed_hash($input, '', $length);
    }

Usage Example

Beispiel #1
0
 /**
  * Execute a block of code.
  * 
  * @param string $code
  * @param boolean $cache
  * @param boolean $do_not_eval
  * @return mixed
  */
 protected static function coreEval(string $code, bool $cache = false, bool $do_not_eval = false)
 {
     \clearstatcache();
     if ($do_not_eval || \Airship\is_disabled('eval')) {
         if ($cache) {
             if (!\file_exists(ROOT . "/tmp/cache/gear")) {
                 \mkdir(ROOT . "/tmp/cache/gear", 0777);
                 \clearstatcache();
             }
             $hashed = Base64UrlSafe::encode(CryptoUtil::raw_hash($code, 33));
             if (!\file_exists(ROOT . '/tmp/cache/gear/' . $hashed . '.tmp.php')) {
                 \file_put_contents(ROOT . '/tmp/cache/gear/' . $hashed . '.tmp.php', '<?php' . "\n" . $code);
             }
             return self::sandboxRequire(ROOT . '/cache/' . $hashed . '.tmp.php');
         } else {
             if (!\file_exists(ROOT . '/tmp/gear')) {
                 \mkdir(ROOT . '/tmp/gear', 0777);
                 \clearstatcache();
             }
             $file = \Airship\tempnam('gear-', 'php', ROOT . '/tmp/gear');
             \file_put_contents($file, '<?php' . "\n" . $code);
             \clearstatcache();
             $ret = self::sandboxRequire($file);
             \unlink($file);
             \clearstatcache();
             return $ret;
         }
     } else {
         return eval($code);
     }
 }
All Usage Examples Of ParagonIE\Halite\Util::raw_hash