3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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); ?>
based on RZqcW
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.2.0
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!"
Output for hhvm-3.12.14 - 3.17.3
Warning: 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!"