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;
}