Reputation: 403
I need to encrypt passwords and some other data in my PHP(5.5.9) application on Ubuntu (14.04) server. I read about libsodium and found it a good fit for the applications requirements. I followed all the instructions given in the only tutorial available for libsoidum.
When I check phpinfo() page I am able to see the entry for libsodium as follows:
libsodium support enabled
libsodium compiled version 1.0.6
libsodium headers version 1.0.3
libsodium library version 1.0.3
However, when I try to run the basic example given in the above tutorial which is:
<?php var_dump([ \Sodium\library_version_major(),\\Sodium\library_version_minor(),\Sodium\version_string() ]);?>
I get an error saying "Call to undefined function Sodium\library_version_major()".
This is really baffling me as the extension is identified correctly by phpinfo() page.
Can anyone please help me in understanding if I am missing something or doing wrong that I am not able to use libsodium with php. Any help is greatly appreciated.
Thank you.
Upvotes: 3
Views: 2633
Reputation: 317
I assume that you've tried to run the basic example from the command line. In this case it is necessary to not only add extension=libsodium.so
to the php.ini of apache2 that is found at /etc/php5/apache2/php.ini on Ubuntu 14.04.
Additional it is necessary to add this line to the php.ini file for the cli environment found at /etc/php5/cli/php.ini.
Upvotes: 2