0

libsodium WAS working fine but now I managed to break it and can't find how to unbreak it.

Amazon AWS Ubuntu Xenial, libsodium18 installed, php-sodium from Ondrej Sury PPA installed but instead of working I now get:

Undefined constant 'Sodium\CRYPTO_SECRETBOX_NONCEBYTES'

The annoying thing is it's fine in Zesty but there's no stable AWS Zesty image still. I'm sure I've just forgotten some simple thing but it's just ceased working.

1

2 Answers 2

2

Found it.

PHP sodium function names have changed so instead of calling \Sodium\crypto_secretbox_open() you now have to call sodium_crypto_secretbox_open()

I seriously hope this post helps someone avoid the grief I've had in the last 24 hours wondering what I'd *^&%'d up - it might well be the only thing on the internet actually pointing this change out that Google finds...

The revised function names and constants are all listed at https://paragonie.com/book/pecl-libsodium/read/01-quick-start.md

Sign up to request clarification or add additional context in comments.

Comments

0

The project description explains the reason behind these changes: https://github.com/jedisct1/libsodium-php

There is also a polyfill that provides the old interface: https://github.com/mollie/polyfill-libsodium

However, new libsodium APIs are not available using this polyfill.

I can't maintain both versions, sorry. I wish we could have kept using the original, namespaced version.

1 Comment

I understand the reasons - I assume it's because it's merging into PHP V7.2 which is an excellent thing, no problem with that at all, most welcome! It's just that the only mention of the change that's easy/fast for devs to find might be this post... Anyway being StackOverflow this post gets quite a high position in google results for 'php sodium broken' so with luck problem solved :D Looking forward to V7.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.