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, openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC')))),'+/=', '-_,')); } $encrypted = encrypt($data, $secretKey); function decrypt($encrypted, $secretKey) { return trim(openssl_decrypt(base64_decode(strtr($encrypted,'-_,', '+/=')),'AES-256-CBC', $secretKey, 0, openssl_cipher_iv_length('AES-256-CBC'))); } $decrypted = decrypt($encrypted, $secretKey); var_dump('Encrypted: ' . $encrypted); var_dump('Decrypted: ' . $decrypted);
Output for 7.1.25 - 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Call to undefined function openssl_encrypt() in /in/rbcaS:8 Stack trace: #0 /in/rbcaS(10): encrypt('This text will ...', 'mykey') #1 {main} thrown in /in/rbcaS on line 8
Process exited with code 255.
Output for 7.1.7
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: anZWaS9HQ1c1QWxDemg4TkcvSTUwT1N2L2w2SHJQdjhwYml5NW5HSVV2a3pkcFZYemR6ZlZsZytpYUg1MVFyRw,," string(48) "Decrypted: ��Eg>�zCc�k}w��ncrypt using openssl!"
Output for 7.1.6
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: Q1pQUnNnWFpheG0yMmxubFA2SlkvZ01Td2lMbW1SeVFuMTdRbWFmbFM4Q2J5c2RDNHErOC9VYURySHEweEhUYg,," string(48) "Decrypted: ����.ⴗ� �<_Uncrypt using openssl!"
Output for 7.1.5
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: ZWJCTnZkcVN2YVQ4K2w1Z2FwZVZpaCtsODZMaDF0K3FpUFFXUWd6aW80TkNaL0o4VHBpQVR1OVRMU1FqTS9CYg,," string(48) "Decrypted: ] ^��x~����a �Ancrypt using openssl!"
Output for 7.1.4
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: bElROFBhbHBLSVhDMXhqdGhKWnFZVTVMVnpCdDF2QnZvc2paSG5sNm5STnNMU1Z3WEluaGpFNkduOXo1bS9sQQ,," string(48) "Decrypted: O�^�B�7p� SɌ� �ncrypt using openssl!"
Output for 7.1.3
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: a1JGTGZhOWNzM0VtWXNBKzA0Y3hQQ3JsWENTN1ZDdlJES0Y0c2taNXZKa2NTeWNpSmlzQ0c1KzY1MG1LWmFuUg,," string(48) "Decrypted: ��d�'���ϱ9��ncrypt using openssl!"
Output for 7.1.2
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: TEJhNU1MdWtiNE05bjJJME9FenJWSmZFNU1MK3ZXSUVKZG9IK3FRRzNzeitCNThnbHVRODF3cUtNVW9pOGlyeg,," string(48) "Decrypted: �NAZg�R0=9l��"�ncrypt using openssl!"
Output for 7.1.1
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: N3RnZVQ0UjFCMlJqM1RsbS9QTVltRFBPUzdCaFNSS0UxMFJqMnI0Ni9YdHBMQW5ETzZlZWZDMnA4Z3JwanljeQ,," string(48) "Decrypted: ��&L�}�!� ˰�ncrypt using openssl!"
Output for 7.1.0
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: U1kzK1h6emViRytJZ2YxL1Z6M2lxMzM4TzYzQklnbjFMOHdhbStBcmZKb080bWZiZ0lYcmpkNFhMd1FRczQ0VA,," string(48) "Decrypted: �N6���J�\l���]ncrypt using openssl!"
Output for 7.0.20
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: eGROYWhWRUhPRG5QeS9SWTFOQzRLSXZkNXlPZzhDRWdkUlRmbS9XZDlJd3dSN1A3VmR3MDZDT3JMTVlaMXF2aQ,," string(48) "Decrypted: ;�@_��e���o�j}fncrypt using openssl!"
Output for 7.0.19
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: dmRwT3RlUExNa29tcFN3a1QzaGxlUjJYQUsvbkVBY05lYUV0WHl3bVIza1FOeFBFQkZmTkVvMnU5bUFMQjNKbQ,," string(48) "Decrypted: a)%/Q����{<��ncrypt using openssl!"
Output for 7.0.18
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: M0tNcllxNmNNaGFkTm9ONC9aei9NaVYxb2E5Q1o2eFBvRHN3RUxJRkd1SHJhMElkMlpWd2pJZEp6Q2pzbk1oZw,," string(48) "Decrypted: a�k��Jrw�>�##Gncrypt using openssl!"
Output for 7.0.17
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: ZVl6VjNGa1hSOUxYcG5uY0Q0cHo5bnZkejhLQVFsM3B6NUpQTTRxamU2OVlBd1FBTDBuYnZTTXZqRFVvcnQ0Yw,," string(48) "Decrypted: �:4�H�,9�W���ncrypt using openssl!"
Output for 7.0.16
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: cmxjS1U5MC9PSWNySDQrNGlBYzE4SExaTHNrME9BRkEraXlKaUVJRGFQUTlsNUdhd3RxOVJ6L0ptOEtRdEMxUw,," string(48) "Decrypted: ���F֍3 �z�ڻ�ncrypt using openssl!"
Output for 7.0.15
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: WDd2cEJIZlNMZE40SWFYWHo3T0c2UTdkZTQwWUVkb2g5cmd4WmtPMGR5YlJOdWRXbHg0QXk4Z21KR3ZrdFJjSQ,," string(48) "Decrypted: ��;Շf� /�� �ncrypt using openssl!"
Output for 7.0.14
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: L3A4N2xHMENJNXMrdnVvRjhGTlFkNk10ZTVXS01NTVhtNWUwaFczSUdKelEwYitHdmt5UUtxMWZlazg1SGZQdQ,," string(48) "Decrypted: ���𾢸�Ab�wk �ncrypt using openssl!"
Output for 7.0.13
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: YnhRa0tOdEVsOGF5TEwzbEozRmFkRHlwQnhXSkxCT3RBZXJ4TUVZODVGaDJqN0paSUp5am5MZ2R1OFY3a1B5Kw,," string(48) "Decrypted: �Zn�\���-%P�bnncrypt using openssl!"
Output for 7.0.12
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: eW5ydWNpTCtlOXFESEsrUENmMGFTWVVYOWpvMFpGZkVibExPa0hJUzlaRVVEZHNJTWFoUnhaR0puSWwwVUVKNA,," string(48) "Decrypted: ��'�V�h)�G��Dncrypt using openssl!"
Output for 7.0.11
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: bkEwUHdKNGpxWE9SN3FQcExhYmhpUHpIMTFaUEZRQ0NuOWdHbVFoOHowNDIxdEJKVndPZE0zbmd2QjNYVVpjbg,," string(48) "Decrypted: eFm���| �Z4"�ncrypt using openssl!"
Output for 7.0.10
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: MGp5eWlwN1Y5cEU1aG5QV2U2bzVoSFI0cXlBeloyU1AxMlcrU3dkenZONTNKWjR2VnZNSUl2cS9VMjl3Ui9TRw,," string(48) "Decrypted: ���p)�?t;�~��ncrypt using openssl!"
Output for 7.0.9
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: SDlVWi9lUDdQOFU3QlRsSnkwSnRsM2ZiSjZkOEQ4V0VkdjQvWlluUmtTeng0YkF4Y0VZdzR1ZnJGOWxSdXVFbA,," string(48) "Decrypted: 3 �)��g�;���Pncrypt using openssl!"
Output for 7.0.8
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: cENNRXdDbURrVU9LY2RTMDBjT1hFWFNYRUI5YVI3TWNPcElpbE8wRjlBVmc5SDFDRFY3cXZnYXIxWjNnK1hSZA,," string(48) "Decrypted: P��U�yZf\�w�Qv2ncrypt using openssl!"
Output for 7.0.7
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: bFJCNXRMd3BBb3ZhT3FaY0FHRU1LUVBFa2NIOGx3UzVmbmgxMmJEQWRlMktKT0s2cllTNkZnSno1N1FnVG1pVQ,," string(48) "Decrypted: ��S�i��2���ncrypt using openssl!"
Output for 7.0.6
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: dHlvb0MrK3RpMkNHVkF0TXlIcmlWVm5IRVlheldjempzTldLRU56WGdLR0Z5d3piOEZQazM3ZzhudFJqQVowNQ,," string(48) "Decrypted: ���B�|< �޻l%"1ncrypt using openssl!"
Output for 7.0.5
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: VGNiUUwzaThTdFhYQWpKdnVWSWxKaFR2djVSVGRjanRWdlRPbDdDSzF3ckR5U2JwZkVqOFNiUDRzcFJZU0daYQ,," string(48) "Decrypted: .s#� {����M���ncrypt using openssl!"
Output for 7.0.4
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: YkVjdWRVbnNlQUEyZlUxTGlVd2pVSFZvdGYydnVpazhnSldydTVUVlFkcnJkdzFDYkErRStucGFWS2ZsYTRCbA,," string(48) "Decrypted: �0^4�NLo�,��PB?ncrypt using openssl!"
Output for 7.0.3
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: TjhkOUtVSnJUa28xdXRQRUplSmlOMlQ1YmQ1VjhLQkVPQkhuRGRjeHBjb2lFRGlhcEpBVndXNG1kdGRwdkEzMA,," string(48) "Decrypted: �J�������A�ncrypt using openssl!"
Output for 7.0.2
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: NGdib25VOEc1NmdSVmxRMU95eThLNXZ6L3Z0WmxpaE5KdS9tZWo1M3ZVeXdMcmpzRTZ1eDZDdTgyVUdkTE1tSA,," string(48) "Decrypted: �c�B��I�t�� ��ncrypt using openssl!"
Output for 7.0.1
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: VHhWNDV3bW9NWlBrb3U0K3RRK0xVWlZMOVhnQ2hOb21CSXRxMEVzaTZxR0I2UFAxNWxJczdwYld6R1NZMXZXRQ,," string(48) "Decrypted: ��5��Ɩh?~6)6aMncrypt using openssl!"
Output for 7.0.0
Warning: openssl_decrypt(): IV passed is only 2 bytes long, cipher expects an IV of precisely 16 bytes, padding with \0 in /in/rbcaS on line 14 string(99) "Encrypted: ZmRqRnFJL1FpYlcyQldiRHNBYjJGRWx2c0lxeG1ySU5ORUlDdDBxdjl4cFRiQVExNlJBY20reGtWTVpWWGU1Kw,," string(48) "Decrypted: "� lr�L!Y~!��n&�ncrypt using openssl!"

preferences:
180.74 ms | 402 KiB | 215 Q