/*!
Generates an md5 key from the start, stop and file of the template function and returns it.
\return false if the key could not be made.
517149
function placementKey( $placement )
    {
        if ( isset( $placement[0] ) and
             isset( $placement[1] ) and
             isset( $placement[2] ) )
        {
            $input = $placement[0][0] . ',' . $placement[0][1] . "\n";
            $input .= $placement[1][0] . ',' . $placement[1][1] . "\n";
            $input .= $placement[2];
            return md5( $input );
        }
        return false;
    }
1022303
function md5cmn(q, a, b, x, s, t) {
    return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
}
743994
protected function buildKey($key)
    {
        return md5($this->prefix . (is_string($key) ? $key : json_encode($key)));
    }
273039
public function getCacheKey()
  {
    if (!$this->useCache) {
      return false;
    }
    $h = $this->sub;
    $h .= $this->assertionType;
    $h .= $this->privateKey;
    $h .= $this->scopes;
    $h .= $this->serviceAccountName;
    return md5($h);
  }
35766
private function validateMd5()
    {
        return static function (callable $handler) {
            return function (
                CommandInterface $c,
                RequestInterface $r = null
            ) use ($handler) {
                if ($c->getName() !== 'ReceiveMessage') {
                    return $handler($c, $r);
                }

                return $handler($c, $r)
                    ->then(
                        function ($result) use ($c, $r) {
                            foreach ((array) $result['Messages'] as $msg) {
                                if (isset($msg['MD5OfBody'])
                                    && md5($msg['Body']) !== $msg['MD5OfBody']
                                ) {
                                    throw new SqsException(
                                        sprintf(
                                            'MD5 mismatch. Expected %s, found %s',
                                            $msg['MD5OfBody'],
                                            md5($msg['Body'])
                                        ),
                                        $c,
                                        [
                                            'code' => 'ClientChecksumMismatch',
                                            'request' => $r
                                        ]
                                    );
                                }
                            }
                            return $result;
                        }
                    );
            };
        };
    }
383927
public static function keyCreate(){
		return base64_encode(mcrypt_create_iv(
			 mcrypt_get_key_size(self::$crypt_cipher,self::$crypt_mode)
			,self::$crypt_rand
		));
	}
1118201
function _setupKey()
    {
        $key = $this->key;
        $keyLength = strlen($key);
        $keyStream = range(0, 255);
        $j = 0;
        for ($i = 0; $i < 256; $i++) {
            $j = ($j + $keyStream[$i] + ord($key[$i % $keyLength])) & 255;
            $temp = $keyStream[$i];
            $keyStream[$i] = $keyStream[$j];
            $keyStream[$j] = $temp;
        }

        $this->stream = array();
        $this->stream[CRYPT_RC4_DECRYPT] = $this->stream[CRYPT_RC4_ENCRYPT] = array(
            0, // index $i
            0, // index $j
            $keyStream
        );
    }
1043506
private function getFilename($key)
    {
        $filename = ($this->ismd5 == true) ? md5($key) : $key;
        if (!is_dir($this->htmlPath)) return false;
        return $this->htmlPath . '/' . $filename . '.htm';
    }
1217429
function GetThumb($dir, $md5, $filename, $mode, $width = 100, $height = 100)
    {
        $path = realpath(DIR_ROOT . '/' . $dir);
        if (is_file($path . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg'))
        {
            return $dir . '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
        }

        $t = new Image_Toolbox($path . '/' . $filename);
        $t->newOutputSize($width, $height, $mode, false, '#FFFFFF');
        $filename = '/.thumbs/' . $md5 . '_' . $width . '_' . $height . '_' . $mode . '.jpg';
        $t->save($path . $filename, 'jpg', 80);
        chmod($path . $filename, 0666);
        return $dir . $filename;
    }
993523
public function read($key, &$ttlLeft = -1)
    {
        $key = md5($key);

        if (isset($this->cache[$key])) {
            return $this->cache[$key];
        }

        return false;
    }
134971
public function generate()
	{
		$key = call_user_func_array('parent::generate', func_get_args());

		if ($this->hex === true) {
			$this->hex = false;
		}

		return $key;
	}
13919
public function isValidMD5()
  {
    // Get client secret if available
    $client     = $this->getClient();
    $clientSecret = '';
    if ( ! is_null($client)) {
      $clientSecret = $client->secret;
    }
    unset($client);

    // Get md5 data from header
    $md5 = $this->getRequest()->header('CONTENT_MD5');
    
    // Do validation for JSON data
    if ($this->getRequest()->isJson()) {
      $content = $this->getRequest()->getContent();

      if (empty($md5) and empty($content)) {
        return true;
      }

      return (md5($content.$clientSecret) == $md5);
    }

    // Do validation for others than JSON data
    $input = $this->getRequest()->all();

    if ( ! empty($input)) {
      foreach($input as $key => $item) {
        if (str_contains($key, '/')) {
          unset($input[$key]);
        }
      }
    }

    if (empty($md5) and empty($input)) {
      return true;
    }

    return (md5(http_build_query($input).$clientSecret) == $md5);
  }
1301220
private function _make_hash(): string
  {
    $args = \func_get_args();
    if ( (\count($args) === 1) && \is_array($args[0]) ){
      $args = $args[0];
    }
    $st = '';
    foreach ( $args as $a ){
      $st .= \is_array($a) ? serialize($a) : '--'.$a.'--';
    }
    return $this->hash_contour.md5($st).$this->hash_contour;
  }
268748
static public function exists($key)
    {
        $keyMD5 = md5(self::$keyPrefix . serialize($key));
        $dir = self::getLocksDir();
        if (!is_dir($dir)) {
            return false;
        }
        $filename = $dir . $keyMD5 . '.lock';
        set_error_handler(function($errno, $errstr) {
            throw new \Exception($errstr);
        });
        try {
            $filePointer = fopen($filename, "w");
            if ($filePointer !== false) {
                $wouldBlock = null;
                if (flock($filePointer, LOCK_EX | LOCK_NB, $wouldBlock)) {
                    restore_error_handler();
                    return false;
                } else {
                    restore_error_handler();
                    return $wouldBlock === 1;
                }
            }
        } catch (\Exception $e) {
            
        }
        restore_error_handler();
        throw new \Exception('Cannot check if lock named "' . $key . '" exists.');
    }
20805
public static function md5Verify($prestr, $sign, $key) {
        $prestr = $prestr . $key;
        $mysgin = md5($prestr);

        if($mysgin == $sign) {
            return true;
        }
        else {
            return false;
        }
    }
1276132
public function getKey()
    {
        if (!isset($this->key)) {
            $this->key = md5(microtime().rand());
        }
        return $this->key;
    }
466114
protected function generate_key( $length = 64 ) {
		$unique  = md5( microtime() . rand() );
		$prepend = $this->identifier . '_batch_';

		return substr( $prepend . $unique, 0, $length );
	}