Check client content MD5.

@return boolean
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);
  }
374605
public function doHash() {
        return md5($this->apiKey . $this->url . $this->data . $this->date . $this->secretKey);
    }
798541
private function isCheckMD5($options)
    {
        return $this->getValue($options, self::OSS_CHECK_MD5, false, true, true);
    }
1193024
public static function checkOnDisk()
    {
        $args = func_get_args();
        if (count($args) == 2)
            $module = $args[0] . DIRECTORY_SEPARATOR . $args[1];
        elseif (count($args) == 1)
            $module = $args[1];
        else
            throw  new \Exception();
        $module = str_replace('\\', DIRECTORY_SEPARATOR, $module);
        return (bool)app('files')->exists(app_path('Modules') . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'Module.php');
    }
1100210
public function validate(string $secretKey): bool
    {
        $contentMD5 = $this->request->getHeader('Content-MD5');

        if ($contentMD5) {
            // We need to validate the integrity of the request
            $body = $this->request->getBody();
            $this->request->setBody($body);

            if ($contentMD5 !== base64_encode(md5((string) $body, true))) {
                // content-md5 header did not match md5 signature of body
                $this->errorCode = self::ERR_MD5CHECKSUMWRONG;

                return false;
            }
        }

        if (!$requestDate = $this->request->getHeader('x-amz-date')) {
            $requestDate = $this->request->getHeader('Date');
        }

        if (!$this->validateRFC2616Date((string) $requestDate)) {
            return false;
        }

        $amzHeaders = $this->getAmzHeaders();

        $signature = base64_encode(
            $this->hmacsha1($secretKey,
                $this->request->getMethod()."\n".
                $contentMD5."\n".
                $this->request->getHeader('Content-type')."\n".
                $requestDate."\n".
                $amzHeaders.
                $this->request->getUrl()
            )
        );

        if ($this->signature !== $signature) {
            $this->errorCode = self::ERR_INVALIDSIGNATURE;

            return false;
        }

        return true;
    }
1027263
public function checksum()
    {
        $properties = serialize($this->properties);
        $calls = serialize($this->getSanitizedCalls());

        return md5($properties.$calls);
    }
77514
protected function checkCacheVersion()
    {
        $fileName = $this->getVersionFileName();

        if (!file_exists($fileName)) {
            return false;
        }

        $version = md5($this->boltVersion);
        $cached = file_get_contents($fileName);

        if ($version === $cached) {
            return true;
        }
        $this->versionChange = true;

        return false;
    }
700603
public function hasRealContent()
    {
        if (count($this->contentAttributes) > 0) return true;

        foreach ($this->childNodes as $node) {
            if (!$node instanceof PHPTAL_Dom_Text || $node->getValueEscaped() !== '') return true;
        }
        return false;
    }
888751
protected function checkHTML5()
    {
        if (in_array($this->_browser_name, ['Opera', 'Internet Explorer', 'Firefox', 'Iceweasel', 'Safari', 'Chrome', 'iPhone', 'iPod'])) {
            switch ($this->_browser_name) {
                case 'Opera':
                    if ($this->_version >= 10)
                        $this->_is_html5 = true;
                    break;
                case 'Internet Explorer':
                    if ($this->_version >= 9)
                        $this->_is_html5 = true;
                    if ($this->_chrome_frame === true && $this->_chrome_frame_version >= 6)
                        $this->_is_html5 = true;
                    break;
                case 'Firefox':
                case 'Iceweasel':
                    if ($this->_version >= 4)
                        $this->_is_html5 = true;
                    break;
                case 'Safari':
                    if ($this->_version >= 5)
                        $this->_is_html5 = true;
                    break;
                case 'Chrome':
                    if ($this->_version >= 9)
                        $this->_is_html5 = true;
                    break;
                case 'iPhone':
                case 'iPod':
                    $this->_is_html5 = true;
                    break;
            }
        }
    }
1313207
public function check()
	{
		if (isset($this->check)) {
			return $this->check;
		}
		
		try {
			Authorizer::validateAccessToken();
			$this->type = 'user';
			return $this->check = true;
		} catch (Exception $e) {}
		
		$client_id     = Request::input('client_id');
		$client_secret = Request::input('client_secret');
		if (!$client_id || !$client_secret) {
			return $this->check = false;
		}
		
		$client = $this->fetchClient($client_id, $client_secret);
		if (!$client) {
			return $this->check = false;
		}
		
		if (!in_array('client_id_secret', $client->grants())) {
			return $this->check = false;
		}
		
		$this->client = $client;
		$this->type = 'client';
		return $this->check = true;
	}
674754
private function readContent(): bool
    {
        $rawContent = $this->getRequest()->getRawContent();
        if ($rawContent === '') {
            $this->content = null;

            return true;
        }

        $this->content = json_decode($rawContent, true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            $this->getResponse()->setStatusCode(new StatusCode(StatusCode::BAD_REQUEST));

            return false;
        }

        return true;
    }
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;
                        }
                    );
            };
        };
    }
1066044
function get_all_components_md5() {

    /// Check requisites are passed
        if (!$this->requisitesok) {
            return false;
        }

    /// Initialize components array
        $comp_arr = array();

    /// Define and retrieve the full md5 file
        if ($this->zippath) {
            $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->md5filename;
        } else {
            $source = $this->sourcebase.'/'.$this->md5filename;
        }

    /// Check if we have downloaded the md5 file before (per request cache)
        if (!empty($this->cachedmd5components[$source])) {
            $comp_arr = $this->cachedmd5components[$source];
        } else {
        /// Not downloaded, let's do it now
            $availablecomponents = array();

            if ($contents = download_file_content($source)) {
            /// Split text into lines
                $lines=preg_split('/\r?\n/',$contents);
            /// Each line will be one component
                foreach($lines as $line) {
                    $availablecomponents[] = explode(',', $line);
                }
            /// If no components have been found, return error
                if (empty($availablecomponents)) {
                    $this->errorstring='cannotdownloadcomponents';
                    return false;
                }
            /// Build an associative array of components for easily search
            /// applying trim to avoid linefeeds and other...
                $comp_arr = array();
                foreach ($availablecomponents as $component) {
                /// Avoid sometimes empty lines
                    if (empty($component[0])) {
                        continue;
                    }
                    $component[0]=trim($component[0]);
                    if (!empty($component[1])) {
                        $component[1]=trim($component[1]);
                    }
                    if (!empty($component[2])) {
                        $component[2]=trim($component[2]);
                    }
                    $comp_arr[$component[0]] = $component;
                }
            /// Cache components
                $this->cachedmd5components[$source] = $comp_arr;
            } else {
            /// Return error
                $this->errorstring='remotedownloaderror';
                return false;
            }
        }
    /// If there is no commponents or erros found, error
        if (!empty($this->errorstring)) {
             return false;

        } else if (empty($comp_arr)) {
             $this->errorstring='cannotdownloadcomponents';
             return false;
        }
        return $comp_arr;
    }
1057289
public function contents()
		{
			if (true === $this->_enabled) {
				for ($i = 0; $i< $this->_zip->numFiles; ++$i) {
					$this->_contents[$i] = $this->_zip->statIndex($i);
					$comment = $this->_zip->getCommentIndex($i);

					if ($comment) {
						$this->_contents[$i]['comment'] = $comment;
					}
				}

				return (!is_null($this->_contents)) ? $this->_contents : false;
			}

			return false;
		}
261277
public function md5()
    {

        if( isset( $this->filePath ) ) {

            return md5_file( $this->filePath );

        } elseif( $this->oid ) {

            $query = new Query(
                "SELECT common.md5( %oid:oid|cast% );",
                array(
                    'oid' => $this->oid
                )
            );

            // execute the query and return the result
            return $this->oid->pg->query( $query )->fetch( Result::FETCH_SINGLE );

        }

        throw \LogicException("Shouldn't ever get tripped");

    }
741927
public function getKey(): string
    {
        if ($this->key === null) {
            $this->key = md5($this->getContent());
        }
        return $this->key;
    }
1307401
protected function fileGetContentsCheck()
    {
        $contents = file_get_contents($this->endPoint);
        $contents = $this->cleanUp($contents);

        if ($contents === '[OK]') {
            return true;
        }

        return false;
    }