As the title suggest i am having difficulty in passing the value of a nonce publicly through a form. I have tried using both a hidden field in the form and passing the value as a parameter in the url.
The nonce is created using:
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES)
When I try to use the retrieved value (eg sodium_crypto_secretbox_open) form either a hidden field (POST) or the url (GET) the following error is returned:
Uncaught SodiumException: nonce size should be SODIUM_CRYPTO_SECRETBOX_NONCEBYTES bytes
I appreciate that the size of the nonce string is being affected, but I have no idea how to counter this issue.
When I echo out the retrieved nonce it looks fine. There appears to be an issue after the nonce is echo'd out that it changes size and is deemed inappropriate to be used by sodium.
Any advice would be greatly appreciated.