Verify that the encryption payload is valid.

@param  mixed  $payload
@return bool
322627
public function validPayload($payload)
    {
        return is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac']) &&
               strlen(base64_decode($payload['iv'], true)) === openssl_cipher_iv_length($this->cipher);
    }
523981
public function verify(Signer $signer, $payload, $key)
    {
        return $signer->verify($this->hash, $payload, $key);
    }
1048987
public function encode(Payload $payload)
    {
        $token = $this->provider->encode($payload->get());

        return new Token($token);
    }
544432
public function isValid(string $key) : bool
    {
        if (!$this->headers->has($this->algorithmHeader)) {
            return false;
        }

        if (!$this->headers->has($this->signatureHeader)) {
            return false;
        }

        $signature = new Signature(new Payload($this->request), $this->getAlgorithm(), $key);

        return $signature->equals($this->getSignature());
    }
298602
protected function verifyRangeTypes(&$payload){
        
        if(isset($payload['query_type']) && is_array($payload['query_type'])){
            $payload['query_type'] = json_encode($payload['query_type']);
        }
        
        return true;
    }
777316
public static function decrypt($keyinfo, $payload)
	{
		if (isset($keyinfo->secret) && isset($keyinfo->hash) && function_exists('mcrypt_decrypt')) {
			ob_start();
			$decrypted = json_decode(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $keyinfo->secret, base64_decode($payload), MCRYPT_MODE_NOFB, $keyinfo->hash)), true);
			ob_end_clean();
		} else {
			$decrypted = false;
		}
		return $decrypted;
	}
1100299
public static function validate($payload, $secret, $signature)
    {
        return hash_equals(self::compute($payload, $secret), $signature);
    }
82623
protected function isValid($response)
    {
        if (is_null($response)) {
            return true;
        }
        if (app('request') instanceof Request) {
            return $response->getStatusCode() !== 401;
        }
        return true;
    }
1254044
public static function simplePayload(array $payload) : array
    {
        $payload = array_filter($payload, function ($val) {
            if ($val instanceof PayloadInterface) {
                $val = $val->getPayload();
            }

            // this will effectively remove empty arrays
            if (is_array($val) && empty($val)) {
                return false;
            }

            if (is_null($val)) {
                return false;
            }

            if ($val === '') {
                return false;
            }

            return true;
        });

        foreach ($payload as $key => $val) {
            if (is_array($val)) {
                $payload[$key] = static::simplePayload($val);
            } elseif ($val instanceof PayloadInterface) {
                $payload[$key] = static::simplePayload($val->getPayload());
            }
        }

        return $payload;
    }
394839
public function canHandle($payload)
    {
        if (is_object($payload) && is_a($payload, $this->payloadClassName)) {
            return true;
        } elseif (is_string($payload) && is_subclass_of($payload, $this->payloadClassName)) {
            return true;
        } else {
            return false;
        }
    }
30507
public function body($payload)
    {
        if (!empty($payload) || is_array($payload)) {
            $this->payload = $payload;
        }

        return $this;
    }
1271547
public function fill($payload)
    {
        $payload = $this->determineTypeAndMessage($payload);
        $payload = $this->fillBlanks($payload);
        return $payload;
    }
213239
public function decrypt($payload)
    {
        $payload = $this->_getJsonPayload($payload);
        $iv = base64_decode($payload['iv']);
        $decrypted = openssl_decrypt($payload['value'], $this->_cipher, $this->_key, 0, $iv);

        if ($decrypted === false) {
            throw new AnEncrypterException('Could not decrypt the data.');
        }

        return unserialize($decrypted);
    }
875581
public function isValid($token)
    {
        try {
            $publicKey = openssl_pkey_get_public(file_get_contents($this->projectDir . '/var/jwt/public.pem'));

            $jws = SimpleJWS::load($token);

            return $jws->verify($publicKey, self::ALG) && $this->isTokenNotExpired($token);
        } catch (\InvalidArgumentException $ex) {
            return false;
        }
    }
1187334
public function process(Payload $payload) {
		$sha1 = $payload->getHead()->getId();
		$tag = substr($payload->getRef(), strlen(self::PATTERN_TAG_HEAD));
		$this->validateVersionNumber($tag);

		// additional settings not requiring validation.
		$url = $this->getSettingValue(self::OPTION_URL, $payload->getRepository()->resolveApiUrl(Repository::API_URL_CLONE));
		// look for an upload comment in settings; if not found there, use Payload HEAD's message body
		$comment = $this->getSettingValue(self::OPTION_COMMENT, $payload->getHead()->getMessage());

		// validation: credentials file and local directory path.
		$directory = $this->getSettingValue(self::OPTION_DIRECTORY);
		$directory = rtrim($directory, '/') . '/';
		$directory .= $sha1 . '/' . $this->getWorkingDirectoryName($payload);
		$credentialsFile = $this->getSettingValue(self::OPTION_CREDENTIALSFILE, GIZZLE_HOME . self::CREDENTIALS_FILE);
		$this->validateCredentialsFile($credentialsFile);
		list ($username, $password) = $this->readUploadCredentials($credentialsFile);

		// initializing build directory and cloning source
		$clone = $this->getGitClonePlugin();
		$clonePluginSettings = $this->getSubPluginSettings('\NamelessCoder\GizzleGitPlugins\GizzlePlugins\ClonePlugin', array(
			ClonePlugin::OPTION_GITCOMMAND => $this->getSettingValue(self::OPTION_GITCOMMAND, ClonePlugin::DEFAULT_GITCOMMAND),
			ClonePlugin::OPTION_DIRECTORY => $directory,
			ClonePlugin::OPTION_SINGLE => TRUE,
			ClonePlugin::OPTION_BRANCH => $tag,
			ClonePlugin::OPTION_DEPTH => 1
		));
		$clone->initialize($clonePluginSettings);
		$this->createWorkingDirectory($directory);
		$this->validateDirectory($directory);
		$clone->process($payload);

		// a large, properly formatted data file.
		$comment = sprintf($comment, $url);
		try {
			$output = $this->getUploader()->upload($directory, $username, $password, $comment);
		} catch (\SoapFault $error) {
			throw new \RuntimeException($error->getMessage(), $error->getCode());
		}

		// cleanup and messages
		if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REMOVEBUILD, FALSE)) {
			$this->removeWorkingDirectory($this->getSettingValue(self::OPTION_DIRECTORY), $sha1);
		}
		$payload->getResponse()->addOutputFromPlugin($this, $output);
	}
617734
protected function validMac(array $payload)
    {
        $bytes = Str::randomBytes(16);

        $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true);

        return Str::equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calcMac);
    }
514248
private function verifyWebhookApi($payload, $hmac_header)
    {
        //Request Data
        $requestData = $this->dataObjectFactory->create();
        $requestData->setApiData(json_decode($payload));
        $requestData->setDynamicApiUrl(ApiHelper::API_VERIFY_SIGNATURE);
        $requestData->setApiKey($this->configHelper->getApiKey());

        $headers = [
            self::HMAC_HEADER => $hmac_header
        ];

        $requestData->setHeaders($headers);

        $requestData->setStatusOnly(true);

        //Build Request
        $request = $this->apiHelper->buildRequest($requestData);
        try {
            $result = $this->apiHelper->sendRequest($request);
        } catch (\Exception $e) {
            return false;
        }

        return $result == 200;
    }