sodium_crypto_pwhash_str
Get an ASCII-encoded hash.
sodium_crypto_pwhash_str Function synopsis
sodium_crypto_pwhash_str(
    string $password,
    int $opslimit,
    int $memlimit
  ): string
Parameters
$password 
Typestring
string; The password to generate a hash for.
$opslimit 
Typeint
Represents a maximum amount of computations to perform. Raising this number will make the function require more CPU cycles to compute a key. There are constants available to set the operations limit to appropriate values depending on intended use, in order of strength: SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE and SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE.
$memlimit 
Typeint
The maximum amount of RAM that the function will use, in bytes. There are constants to help you choose an appropriate value, in order of size: SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE, and SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE. Typically these should be paired with the matching opslimit values.
Return value
Typestring
Returns the hashed password.
In order to produce the same password hash from the same password, the same values for $opslimit and $memlimit must be used. These are embedded within the generated hash, so
everything that's needed to verify the hash is included. This allows
the sodium_crypto_pwhash_str_verify function to verify the hash without
needing separate storage for the other parameters.
Changes to the sodium_crypto_pwhash_str Function 
PHP 8.2
- Attribute added for parameter 
$password:#[SensitiveParameter] 
PHP 8.0
- Return type added: 
string - Parameter type added for parameter #1 (
$password):string - Parameter type added for parameter #2 (
$opslimit):int - Parameter type added for parameter #3 (
$memlimit):int 
  sodium_crypto_pwhash_str(
-     $password,
+     string $password,
-     $opslimit,
+     int $opslimit,
-     $memlimit
+     int $memlimit
-   )
+   ): string  PHP 7.2
- Function added
 
sodium_crypto_pwhash_str Function Availability
sodium_crypto_pwhash_str Function Availability| PHP Version | Availability | 
|---|---|
| PHP 8.6Future Release | Yes | 
| PHP 8.5Upcoming Release | Yes | 
| PHP 8.4Supported (Latest) | Yes | 
| PHP 8.3Supported | Yes | 
| PHP 8.2Security-Fixes Only | Yes | 
| PHP 8.1Security-Fixes Only | Yes | 
| PHP 8.0Unsupported | Yes | 
| PHP 7.4Unsupported | Yes | 
| PHP 7.3Unsupported | Yes | 
| PHP 7.2Unsupported | Yes | 
| PHP 7.1Unsupported | No | 
| PHP 7.0Unsupported | No | 
| PHP 5.6Unsupported | No | 
| PHP 5.5Unsupported | No | 
| PHP 5.4Unsupported | No | 
| PHP 5.3Unsupported | No |