Back to Aes class

Method isSupported

public static bool
isSupported
()
Is AES encryption supported by this PHP installation?
Returns
  • bool
Class: Aes
Project: Joomla

Method isSupported - Source code

/**
 * Is AES encryption supported by this PHP installation?
 *
 * @return boolean
 */
public static function isSupported()
{
    $adapter = new OpenSSL();
    if (!$adapter->isSupported()) {
        $adapter = new Mcrypt();
        if (!$adapter->isSupported()) {
            return false;
        }
    }
    if (!\function_exists('base64_encode')) {
        return false;
    }
    if (!\function_exists('base64_decode')) {
        return false;
    }
    if (!\function_exists('hash_algos')) {
        return false;
    }
    $algorithms = hash_algos();
    if (!\in_array('sha256', $algorithms)) {
        return false;
    }
    return true;
}