I want to use Argon2i to hash my password but it's not working. I get the following error:
Fatal error: Uncaught Error: Call to undefined function Sodium\crypto_pwhash_str()
This is the guide I'm using to install libsodium: https://paragonie.com/book/pecl-libsodium/read/00-intro.md#installing-libsodium
I have checked that libsodium is installed and working.
I implemented the Argon2i hashing that I got from this link: https://paragonie.com/blog/2016/02/how-safely-store-password-in-2016
Here is the code from that link:
// Password hashing:
$hash_str = \Sodium\crypto_pwhash_str(
$password,
\Sodium\CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
\Sodium\CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE
);
What could be the problem?
The most likely cause for this problem is an outdated version of libsodium, often because Linux distribution patches erroneously only provide libsodium version 1.0.3 or 1.0.8 despite 1.0.11 being available.
Installing Libsodium in a PHP project requires installing two different things:
libsodium, the library itselfext/libsodium, the PHP extension (if this becomes a core extension, we'll probably shorten it to ext/sodium instead)In order to use \Sodium\crypto_pwhash_str(), two conditions must be met:
In Halite, we have a function called Halite::isLibsodiumSetupCorrectly() to quickly diagnose version issues.
Your best best is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With