3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Some example variables: $alice_ecdh_secret = "Hallo"; $bob_ecdh_public = "Welt"; $message_keypair = sodium_crypto_box_keypair_from_secretkey_and_publickey( $alice_ecdh_secret, $bob_ecdh_public ); $plaintext = "This is a secret message for your eyes only."; $nonce = random_bytes(24); // And now for the actual public-key encryption step: $ciphertext = sodium_crypto_box($plaintext, $nonce, $message_keypair);
Output for 7.2.0 - 7.2.13, 7.3.0
Fatal error: Uncaught SodiumException: secretkey should be SODIUM_CRYPTO_BOX_SECRETKEYBYTES bytes in /in/dp2jm:10 Stack trace: #0 /in/dp2jm(10): sodium_crypto_box_keypair_from_secretkey_and_publickey() #1 {main} thrown in /in/dp2jm on line 10
Process exited with code 255.
Output for 7.0.33, 7.1.0 - 7.1.25
Fatal error: Uncaught Error: Call to undefined function sodium_crypto_box_keypair_from_secretkey_and_publickey() in /in/dp2jm:8 Stack trace: #0 {main} thrown in /in/dp2jm on line 8
Process exited with code 255.
Output for 5.6.38
Fatal error: Call to undefined function sodium_crypto_box_keypair_from_secretkey_and_publickey() in /in/dp2jm on line 8
Process exited with code 255.

preferences:
70.32 ms | 401 KiB | 48 Q