Function is expecting salt length to be EXACTLY SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES bytes. It throws error if you provide longer salt string. For example: salt of 64 bytes will throw an error.(PHP 7 >= 7.2.0, PHP 8)
sodium_crypto_pwhash_scryptsalsa208sha256 — Derives a key from a password, using scrypt
$length,$password,$salt,$opslimit,$memlimitThis is the scrypt counterpart to sodium_crypto_pwhash().
A common reason to use this particular function is to derive the seeds for cryptographic keys from a password and salt, and then use these seeds to generate the actual keys needed for some purpose (e.g. sodium_crypto_sign_detached()).
lengthpasswordsaltSODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES bytes.
opslimitSODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE and SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE.
memlimitSODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE and SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE. Typically these should be paired with the matching opslimit values.
A string of bytes of the desired length.