3v4l.org

run code in 300+ PHP versions simultaneously
<?php $secret_key = 'denemesmdnoandowinadanw'; echo $secret_key . PHP_EOL; $message = 'Sensitive information'; $nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES); $encrypted_message = sodium_crypto_secretbox($message, $nonce, $secret_key); $encrypted_message = sodium_bin2hex($encrypted_message); echo $encrypted_message . PHP_EOL; $encrypted_message = sodium_hex2bin($encrypted_message); $decrypted_message = sodium_crypto_secretbox_open($encrypted_message, $nonce, $secret_key);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
denemesmdnoandowinadanw Fatal error: Uncaught SodiumException: sodium_crypto_secretbox(): Argument #3 ($key) must be SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes long in /in/umhHi:10 Stack trace: #0 /in/umhHi(10): sodium_crypto_secretbox() #1 {main} thrown in /in/umhHi on line 10
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
denemesmdnoandowinadanw Fatal error: Uncaught SodiumException: key size should be SODIUM_CRYPTO_SECRETBOX_KEYBYTES bytes in /in/umhHi:10 Stack trace: #0 /in/umhHi(10): sodium_crypto_secretbox() #1 {main} thrown in /in/umhHi on line 10
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
denemesmdnoandowinadanw Notice: Use of undefined constant SODIUM_CRYPTO_SECRETBOX_NONCEBYTES - assumed 'SODIUM_CRYPTO_SECRETBOX_NONCEBYTES' in /in/umhHi on line 9 Fatal error: Uncaught TypeError: random_bytes() expects parameter 1 to be integer, string given in /in/umhHi:9 Stack trace: #0 /in/umhHi(9): random_bytes('SODIUM_CRYPTO_S...') #1 {main} thrown in /in/umhHi on line 9
Process exited with code 255.
Output for 5.0.2 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
denemesmdnoandowinadanw Fatal error: Call to undefined function random_bytes() in /in/umhHi on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/umhHi on line 5 denemesmdnoandowinadanwPHP_EOL Fatal error: Call to undefined function random_bytes() in /in/umhHi on line 9
Process exited with code 255.
Output for 4.4.5 - 4.4.9
denemesmdnoandowinadanw Fatal error: Call to undefined function: random_bytes() in /in/umhHi on line 9
Process exited with code 255.
Output for 4.3.10 - 4.3.11, 4.4.0 - 4.4.4
denemesmdnoandowinadanw Fatal error: Call to undefined function: random_bytes() in /in/umhHi on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/umhHi on line 5 denemesmdnoandowinadanwPHP_EOL Fatal error: Call to undefined function: random_bytes() in /in/umhHi on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/umhHi on line 5 denemesmdnoandowinadanwPHP_EOL Fatal error: Call to undefined function: random_bytes() in /in/umhHi on line 9

preferences:
101.74 ms | 416 KiB | 5 Q