3v4l.org

run code in 500+ 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: ' . $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.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/th9Jm:8 Stack trace: #0 /in/th9Jm(10): encrypt('This text will ...', 'mykey') #1 {main} thrown in /in/th9Jm 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/th9Jm on line 8 string(99) "Encrypted: MExJOHFya0ZUOFZTSjlRU1JybzlDbTZoZ01tendrYXYxbFZQQzI4U3Y5ampNQmxoSkhxUXdlaGQyS2JRbFdGQw,," string(48) "Decrypted: This text will encrypt using openssl!"

preferences:
120.24 ms | 1689 KiB | 4 Q