ParagonIE\Halite\Halite::isLibsodiumSetupCorrectly PHP Method

isLibsodiumSetupCorrectly() public static method

Is Libsodium set up correctly? Use this to verify that you can use the newer versions of Halite correctly.
public static isLibsodiumSetupCorrectly ( boolean $echo = false ) : boolean
$echo boolean
return boolean
    public static function isLibsodiumSetupCorrectly(bool $echo = false) : bool
    {
        // Require libsodium 1.0.9
        $major = \Sodium\library_version_major();
        $minor = \Sodium\library_version_minor();
        if ($major < 9 || $major === 9 && $minor < 2) {
            if ($echo) {
                echo 'Halite needs libsodium 1.0.9 or higher. You have: ', \Sodium\version_string(), "\n";
            }
            return false;
        }
        // Added in version 1.0.3 of the PHP extension
        if (!\is_callable('\\Sodium\\crypto_pwhash_str')) {
            if ($echo) {
                echo 'Halite needs version 1.0.6 or higher of the PHP extension installed.', "\n";
            }
            return false;
        }
        if (!\is_callable('\\Sodium\\crypto_box_seal')) {
            if ($echo) {
                echo 'crypto_box_seal() is not available.', "\n";
            }
            return false;
        }
        return true;
    }

Usage Example

Beispiel #1
0
        exit(255);
    }
}
if (!isset($_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = '';
}
/**
 * 2. Load the Airship functions
 */
require_once ROOT . '/Airship.php';
/**
 * 3. Let's autoload the composer packages
 */
require_once \dirname(ROOT) . '/vendor/autoload.php';
// Let's also make sure we're using a good version of libsodium
if (!Halite::isLibsodiumSetupCorrectly()) {
    die("Airship requires libsodium 1.0.9 or newer (with a stable version of the PHP bindings).");
}
/**
 * 4. Autoload the Engine files
 */
\Airship\autoload('Airship\\Alerts', '~/Alerts');
\Airship\autoload('Airship\\Engine', '~/Engine');
/**
 * 5. Load up the registry singleton for latest types
 */
$state = State::instance();
// 5a. Initialize the Gears.
require_once ROOT . '/gear_init.php';
/**
 * 6. Load the global functions
All Usage Examples Of ParagonIE\Halite\Halite::isLibsodiumSetupCorrectly