问题
Even I have the right version: Current PHP version: 7.4.11 a simple libsodium implementation like this:
<?php
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES); // 256 bit
?>
is failing with the error message below:
[09-Jan-20...] PHP Warning: Use of undefined constant SODIUM_CRYPTO_SECRETBOX_KEYBYTES - assumed 'SODIUM_CRYPTO_SECRETBOX_KEYBYTES' (this will throw an Error in a future version of PHP) in ../crypto.php on line 3
[09-Jan-20...] PHP Fatal error: Uncaught TypeError: random_bytes() expects parameter 1 to be int, string given in .../crypto.php:3
Stack trace:
#0 .../crypto.php(3): random_bytes('SODIUM_CRYPTO_S...')
#1 {main}
thrown in .../crypto.php on line 3
It looks like PHP do not recognize the libsodium package as mention on documentation:
PHP Encryption With Libsodium Developers can use Sodium for PHP encryption and decryption with PHP 7.2 and newer without an extension.
Should I install something else on my PHP (which is coming with cpanel) to be able to use libsodium?
来源:https://stackoverflow.com/questions/65643104/cpanel-php-7-4-libsodium-missing-is-there-an-extra-setting-required-or-a-modul