Call to undefined function sodium_crypto_secretbox_keygen()
ilnurshax opened this issue · comments
Hello to all!
Call to undefined function sodium_crypto_secretbox_keygen()
I didn't find this function when search this text on Sodium package. But another functions from _secretbox
exists in Sodium package:
- sodium_crypto_secretbox
- sodium_crypto_secretbox_open
How to generate secret key for sodium_crypto_secretbox if sodium_crypto_secretbox_keygen() function does not exist?
P.S. I found that this code could be the solution, but is this solution safe enough?
$secret_key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
@paragonie-scott
Yes, random_bytes()
is exactly what you want.
Forgive the oversight. I'll get these in 1.4.0, due to be released on or before November 30 (PHP 7.2 release date).
Thanks a lot!