CPANEL PHP 7.4 LIBSODIUM missing - is there an extra setting required or a module to turn on?

家住魔仙堡 提交于 2021-01-29 10:33:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!