Checks if an algorithm is symmetric

@param mixed $algorithm The algorithm to check
@return bool True if the algorithm is symmetric, otherwise false
@throws InvalidArgumentException Thrown if the algorithm is not valid
338901
public static function isSymmetric($algorithm) : bool
    {
        if (!self::has($algorithm)) {
            throw new InvalidArgumentException("Algorithm \"$algorithm\" is not valid");
        }

        return in_array($algorithm, [Algorithms::SHA256, Algorithms::SHA384, Algorithms::SHA512]);
    }
566326
function isValidEngine($engine)
    {
        switch ($engine) {
            case self::ENGINE_OPENSSL:
                if ($this->mode == self::MODE_STREAM && $this->continuousBuffer) {
                    return false;
                }
                $this->openssl_emulate_ctr = false;
                $result = $this->cipher_name_openssl &&
                          extension_loaded('openssl') &&
                          // PHP 5.3.0 - 5.3.2 did not let you set IV's
                          version_compare(PHP_VERSION, '5.3.3', '>=');
                if (!$result) {
                    return false;
                }

                // prior to PHP 5.4.0 OPENSSL_RAW_DATA and OPENSSL_ZERO_PADDING were not defined. instead of expecting an integer
                // $options openssl_encrypt expected a boolean $raw_data.
                if (!defined('OPENSSL_RAW_DATA')) {
                    $this->openssl_options = true;
                } else {
                    $this->openssl_options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
                }

                $methods = openssl_get_cipher_methods();
                if (in_array($this->cipher_name_openssl, $methods)) {
                    return true;
                }
                // not all of openssl's symmetric cipher's support ctr. for those
                // that don't we'll emulate it
                switch ($this->mode) {
                    case self::MODE_CTR:
                        if (in_array($this->cipher_name_openssl_ecb, $methods)) {
                            $this->openssl_emulate_ctr = true;
                            return true;
                        }
                }
                return false;
            case self::ENGINE_MCRYPT:
                return $this->cipher_name_mcrypt &&
                       extension_loaded('mcrypt') &&
                       in_array($this->cipher_name_mcrypt, @mcrypt_list_algorithms());
            case self::ENGINE_INTERNAL:
                return true;
        }

        return false;
    }
462507
public function offsetExists($offset)
    {
        if ($offset == $this->querySeparator) {
            return true;
        }

        if (isset($this->array[$offset])) {
            return true;
        }

        $nested = $this->nested();

        return isset($nested[$offset]);
    }
57854
public function has($enumerator): bool
    {
        try {
            $ord = ($this->enumeration)::get($enumerator)->getOrdinal();
            return \array_key_exists($ord, $this->map);
        } catch (InvalidArgumentException $e) {
            // An invalid enumerator can't be contained in this map
            return false;
        }
    }
118994
public static function naturalKeySortRecursive(&$array) {
		if (!is_array($array)) {
			return FALSE;
		}
		uksort($array, 'strnatcasecmp');
		foreach ($array as $key => $value) {
			self::naturalKeySortRecursive($array[$key]);
		}
		return TRUE;
	}
946360
private function getHashAlgorithm(string $algorithm) : string
    {
        switch ($algorithm) {
            case Algorithms::SHA256:
                return 'sha256';
            case Algorithms::SHA384:
                return 'sha384';
            case Algorithms::SHA512:
                return 'sha512';
            default:
                throw new InvalidArgumentException("Algorithm \"$algorithm\" is not a hash algorithm");
        }
    }
623857
protected function isMethodAllowed($method)
    {
        // Make sure $method is string
        if (!is_string($method)) {
            throw new InvalidArgumentException(
                '$method must be string'
            );
        }

        // If method is simple method, always allow
        if ($this->isSimpleMethod($method)) {
            return true;
        }

        return in_array(
            $method,
            $this->config['allowMethods'],
            true
        );
    }
942172
public static function isIndexedArray($array)
    {
        if (! is_array($array)) {
            return false;
        }

        foreach ($array as $key => $value) {
            if (! is_numeric($key)) {
                return false;
            }
        }

        return true;
    }
191806
public static function is_numeric_array($array)
    {
        if (!is_array($array)) { return false; }

        $current = 0;
        foreach (array_keys($array) as $key) {
            if ($key !== $current) { return false; }

            $current++;
        }

        return true;
    }
291114
boolean setAlgorithm(AlgorithmName alg[])
    {
        if (alg != null && alg.length != 0) {
            m_algorithm_ = alg;
            return true;
        }
        return false;
    }
275597
public static boolean isCfmxCompat(String algorithm) {

	if (StringUtil.isEmpty(algorithm, true)) return true;

	return algorithm.equalsIgnoreCase(CFMXCompat.ALGORITHM_NAME);
    }
418603
public function __isset($key)
    {
        if ($this->flag == self::ARRAY_AS_PROPS) {
            return $this->offsetExists($key);
        }

        if (in_array($key, $this->protectedProperties)) {
            throw new \InvalidArgumentException('$key is a protected property, use a different key');
        }

        return isset($this->$key);
    }
197519
public function validateToken($token, $secret, $algorithm = 'HS256')
    {
        try {
            JWT::decode($token, $secret, [$algorithm]);
        } catch(\Exception $e) {
            return false;
        }

        return true;
    }
546706
public static function isSupportedSigningAlgorithm($algorithm)
    {
        return in_array(
            $algorithm,
            array(
                XMLSecurityKey::RSA_1_5,
                XMLSecurityKey::RSA_SHA1,
                XMLSecurityKey::RSA_SHA256,
                XMLSecurityKey::RSA_SHA384,
                XMLSecurityKey::RSA_SHA512
            )
        );
    }
798300
static void check(PublicKey key, AlgorithmId algorithmId)
                        throws CertPathValidatorException {
        String sigAlgName = algorithmId.getName();
        AlgorithmParameters sigAlgParams = algorithmId.getParameters();

        if (!certPathDefaultConstraints.permits(
                SIGNATURE_PRIMITIVE_SET, sigAlgName, key, sigAlgParams)) {
            throw new CertPathValidatorException(
                "algorithm check failed: " + sigAlgName + " is disabled",
                null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
        }
    }
424371
public function getFingerprint(string $algorithm = 'SHA1'): Hash {
        $value = openssl_x509_fingerprint(
            $this->getHandle(),
            $algorithm,
            TRUE
        );
        if(!$value) {
            throw new RuntimeException(OpenSSL::getLastError());
        }
        $hash = new Hash($algorithm);
        $hash->setValue($value);
        return $hash;
    }
1293869
public function has($key)
    {
        if (null === $key) {
            throw new Exception\InvalidArgumentException('The specified key name is null');
        }

        if (!is_scalar($key)) {
            throw new Exception\InvalidArgumentException('The specified key name must be a scalar');
        }

        return array_key_exists($key, $this->collections);
    }