3v4l.org

run code in 300+ PHP versions simultaneously
<?php $key = 'abc'; $string = ' +bgn91Bn1tfUZpeLAPHRhy2oCMWhlUc6kiVZUrg1ao+gvfUx5gwY0f1hfcjBG3JJo+Yx63bhreBPee7If8rTVw== '; // note the spaces $iv = mcrypt_create_iv( mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_DEV_URANDOM ); $encrypted = base64_encode( $iv . mcrypt_encrypt( MCRYPT_RIJNDAEL_256, hash('sha256', $key, true), $string, MCRYPT_MODE_CBC, $iv ) ); $data = base64_decode($encrypted); $iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC)); $decrypted = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, hash('sha256', $key, true), substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC)), MCRYPT_MODE_CBC, $iv ), "\0" ); echo 'Encrypted:' . "\n"; var_dump($encrypted); echo "\n"; echo 'Decrypted:' . "\n"; var_dump($decrypted);
Output for 7.0.6 - 7.0.20, 7.1.0 - 7.1.25, 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.6
Fatal error: Uncaught Error: Call to undefined function mcrypt_create_iv() in /in/fXUes:8 Stack trace: #0 {main} thrown in /in/fXUes on line 8
Process exited with code 255.
Output for 7.0.5
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "GPFteA91zcFI63dl2aBuTA==" Decrypted: string(0) ""
Output for 7.0.4
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "GUPjQiwdx2+2HK89vHMQbQ==" Decrypted: string(0) ""
Output for 7.0.3
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "N+jqEkKvYPFQ5Dx9bd+KLw==" Decrypted: string(0) ""
Output for 7.0.2
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "1ymtmmqMCozLLLXQmMIL5A==" Decrypted: string(0) ""
Output for 7.0.1
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "XBNn5Ft/VK27OfGzeXZ0GA==" Decrypted: string(0) ""
Output for 7.0.0
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 19 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 33 Encrypted: string(24) "Hy4AyrONFNgpROCieKNw5w==" Decrypted: string(0) ""
Output for 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_create_iv() in /in/fXUes on line 8
Process exited with code 255.
Output for 5.6.20
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "8lsDQouKb4rhvyxYZJO9bA==" Decrypted: string(0) ""
Output for 5.6.19
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "9i4dkHi/Tv0UbqH2NmOd0Q==" Decrypted: string(0) ""
Output for 5.6.18
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "Wtc1Vrd1idrWWaV3+wR/rQ==" Decrypted: string(0) ""
Output for 5.6.17
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "4Z8+7QT2KoAXTIhOV0MF9g==" Decrypted: string(0) ""
Output for 5.6.16
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "Wmb7g124KABWbHczUj43tQ==" Decrypted: string(0) ""
Output for 5.6.15
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "6tfSKjHw26x7Thmf8OKYDg==" Decrypted: string(0) ""
Output for 5.6.14
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "8rkCythVxn1saldBEqwQEA==" Decrypted: string(0) ""
Output for 5.6.13
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "vJdbqWINal6WJgSHtbN4iA==" Decrypted: string(0) ""
Output for 5.6.12
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "6Zl9eDWvuVbxSKdX6wvDJA==" Decrypted: string(0) ""
Output for 5.6.11
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "F3LZAtBqtn8xq6m6Vf+1ow==" Decrypted: string(0) ""
Output for 5.6.10
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "GEpvdfVjw6lN2y9qGFaz8g==" Decrypted: string(0) ""
Output for 5.6.9
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "Paanorh2TLReWnhYB9j19g==" Decrypted: string(0) ""
Output for 5.6.8
Warning: mcrypt_encrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 21 Warning: mcrypt_decrypt(): Received initialization vector of size 16, but size 32 is required for this encryption mode in /in/fXUes on line 35 Encrypted: string(24) "9U4NQfJqxZTtKdv8IHxnQw==" Decrypted: string(0) ""
Output for 5.5.34
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "SSOz1MHs/iIhbY2fObK8piRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "�`.g��9�d�Lj{�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.33
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "iQB2ofhT726rYptiYY1N8SRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "C��(ͅk�:�D������?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.32
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "8tb4KzQn4Uy5A53TtHR1cyRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "t�e�sq&� ��������?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.31
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "3qfONYA62EJg1oNJ47+JlyRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "X�S��l�N߼Rv=�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.30
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "l485+zkQKQWAh6XUzLNojCRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "̤H~F���}z������?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.29
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "hMO02YhVUX2TRDP9hZwfECRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "�)j��޽M �4U�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.28
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "m9WR7KzDbDesCw9tTtMkPyRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "� _땫��05��P����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.27
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "RjBkJDyf/T9ZrL6dAk/KHCRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "�s��{�:�w��ų�~s����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.26
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "T4XrV6P+v/22xzGDD2z0hSRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "��v��x^��۾�@�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.25
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "R6mcAwN9pIj3p81PKVGanyRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "���D+c+ٮ���.�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"
Output for 5.5.24
Warning: mcrypt_encrypt(): The IV parameter must be as long as the blocksize in /in/fXUes on line 21 Encrypted: string(152) "FVEHYbXO330IWRIQQWHZ2SRk/sX3n0vnHvHV/yp5OpMw+48PopyqLUdyMJX02I4HpOqRxo+shTtHvw3K7Xzd6Z6IsSEZBhRC86Ep551MJ5xvt2Vn/mZ8UPW03jdG1iKnkO8Db2yPR+qeyYtKiXn4iQ==" Decrypted: string(96) "�����&P-H�m�����?eO��Np�p#��ZMH�X�^N*0347�΋��8��=o�L�k ���Y$ �.� ��o5J���ƋSdk��)�"

preferences:
180.76 ms | 402 KiB | 198 Q