3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = 'This text will encrypt using openssl!'; $secretKey = 'mykey'; function encrypt($data, $secretKey) { return trim(strtr(base64_encode(openssl_encrypt($data, 'AES-256-CBC', $secretKey, 0)),'+/=', '-_,')); } $encrypted = encrypt($data, $secretKey); function decrypt($encrypted, $secretKey) { return trim(openssl_decrypt(base64_decode(strtr($encrypted,'-_,', '+/=')),'AES-256-CBC', $secretKey, 0)); } $decrypted = decrypt($encrypted, $secretKey); var_dump('Encrypted: ' . $encrypted); var_dump('Decrypted: ' . pkcs5_unpad($decrypted)); ?>
Output for 7.1.20 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/RZqcW:8 Stack trace: #0 /in/RZqcW(10): encrypt('This text will ...', 'mykey') #1 {main} thrown in /in/RZqcW on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Warning: openssl_encrypt(): Using an empty Initialization Vector (iv) is potentially insecure and not recommended in /in/RZqcW on line 8 string(99) "Encrypted: MExJOHFya0ZUOFZTSjlRU1JybzlDbTZoZ01tendrYXYxbFZQQzI4U3Y5ampNQmxoSkhxUXdlaGQyS2JRbFdGQw,," Fatal error: Uncaught Error: Call to undefined function pkcs5_unpad() in /in/RZqcW:19 Stack trace: #0 {main} thrown in /in/RZqcW on line 19
Process exited with code 255.

preferences:
162.28 ms | 402 KiB | 210 Q