ParagonIE_Sodium_Compat::use_fallback() protected WP 1.0
Should we use the libsodium core function instead? This is always a good idea, if it's available. (Unless we're in the middle of running our unit test suite.)
If ext/libsodium is available, use it. Return TRUE. Otherwise, we have to use the code provided herein. Return FALSE.
{} It's a method of the class: ParagonIE_Sodium_Compat{}
No Hooks.
Return
true|false
. Null. Nothing.
Usage
$result = ParagonIE_Sodium_Compat::use_fallback( $sodium_func_name );
- $sodium_func_name(string)
- -
Code of ParagonIE_Sodium_Compat::use_fallback() ParagonIE Sodium Compat::use fallback WP 5.7
protected static function use_fallback($sodium_func_name = '')
{
static $res = null;
if ($res === null) {
$res = extension_loaded('libsodium') && PHP_VERSION_ID >= 50300;
}
if ($res === false) {
// No libsodium installed
return false;
}
if (self::$disableFallbackForUnitTests) {
// Don't fallback. Use the PHP implementation.
return false;
}
if (!empty($sodium_func_name)) {
return is_callable('\\Sodium\\' . $sodium_func_name);
}
return true;
}