Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a secret key for the encrypted cookie recipe #18

Open
randy-johnson opened this issue Apr 24, 2019 · 0 comments
Open

How to create a secret key for the encrypted cookie recipe #18

randy-johnson opened this issue Apr 24, 2019 · 0 comments

Comments

@randy-johnson
Copy link

I get this error when trying the encrypted cookie recipe here:
https://paragonie.com/book/pecl-libsodium/read/09-recipes.md#encrypted-cookies

Fatal error: Uncaught SodiumException: unsupported key length in /Users/randy/starter/admin/SodiumCookie.php:106

Line 106 is this:

$encKey = sodium_crypto_generichash(
            sodium_crypto_generichash('encryption', $cookieName),
            $this->key,
            SODIUM_CRYPTO_STREAM_KEYBYTES
        );

I found this in the ebook but it didn't do the trick

$key = random_bytes(SODIUM_CRYPTO_AUTH_KEYBYTES);

How do I properly generate the secret key that is required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant