public static function engine($instance = null)
    {
        if ($instance === null && static::$_instance === null) {
            if (extension_loaded('openssl')) {
                $instance = new OpenSsl();
            } elseif (extension_loaded('mcrypt')) {
                $instance = new Mcrypt();
            }
        }
        if ($instance) {
            static::$_instance = $instance;
        }
        if (isset(static::$_instance)) {
            return static::$_instance;
        }
        throw new InvalidArgumentException(
            'No compatible crypto engine available. ' .
            'Load either the openssl or mcrypt extensions'
        );
    }
public static function engine($instance = null)
    {
        if ($instance === null && static::$_instance === null) {
            if (extension_loaded('openssl')) {
                $instance = new OpenSsl();
            } elseif (extension_loaded('mcrypt')) {
                $instance = new Mcrypt();
            }
        }
        if ($instance) {
            static::$_instance = $instance;
        }
        if (isset(static::$_instance)) {
            return static::$_instance;
        }
        throw new InvalidArgumentException(
            'No compatible crypto engine available. ' .
            'Load either the openssl or mcrypt extensions'
        );
    }
public static function engine ( $ instance = null ) { if ( $ instance === null && static :: $ _instance === null ) { if ( extension_loaded ( 'openssl' ) ) { $ instance = new OpenSsl ( ) ; } elseif ( extension_loaded ( 'mcrypt' ) ) { $ instance = new Mcrypt ( ) ; } } if ( $ instance ) { static :: $ _instance = $ instance ; } if ( isset ( static :: $ _instance ) ) { return static :: $ _instance ; } throw new InvalidArgumentException ( 'No compatible crypto engine available. ' . 'Load either the openssl or mcrypt extensions' ) ; }
Get the crypto implementation based on the loaded extensions.

You can use this method to forcibly decide between mcrypt/openssl/custom implementations.

@param \Cake\Utility\Crypto\OpenSsl|\Cake\Utility\Crypto\Mcrypt|null $instance The crypto instance to use.
@return \Cake\Utility\Crypto\OpenSsl|\Cake\Utility\Crypto\Mcrypt Crypto instance.
@throws \InvalidArgumentException When no compatible crypto extension is available.
Get the crypto implementation based on the loaded extensions .