3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $sharedKey = hash('sha256','0-120913kassaaa'+floor(time() / 360),true); $encAlgo = MCRYPT_RIJNDAEL_256; $mcryptMode = MCRYPT_MODE_ECB; function encrypt_base64_urlenc($secret, $shared) { return urldecode(base64_decode(rtrim(mcrypt_decrypt( $encAlgo, $shared, $secret, $mcryptMode, mcrypt_create_iv( mcrypt_get_iv_size( $encAlgo, $mcryptMode ) ), MCRYPT_DEV_URANDOM ),'\0'))); } function decrypt_base64_urlenc($secret, $shared) { return rtrim(mcrypt_decrypt( $encAlgo, $shared, base64_decode(urldecode($secret)), $mcryptMode, mcrypt_create_iv( mcrypt_get_iv_size( $encAlgo, $mcryptMode ) ), MCRYPT_DEV_URANDOM ), '\0'); } $derp = encrypt_base64_urlenc("this is a secret"); $underp = decrypt_base64_urlenc($derp); echo $derp, "\n"; echo $underp, "\n";
based on oJJjR
Output for 7.1.0
Notice: A non well formed numeric value encountered in /in/a3Nv6 on line 3 Notice: Use of undefined constant MCRYPT_RIJNDAEL_256 - assumed 'MCRYPT_RIJNDAEL_256' in /in/a3Nv6 on line 4 Notice: Use of undefined constant MCRYPT_MODE_ECB - assumed 'MCRYPT_MODE_ECB' in /in/a3Nv6 on line 5 Fatal error: Uncaught ArgumentCountError: Too few arguments to function encrypt_base64_urlenc(), 1 passed in /in/a3Nv6 on line 39 and exactly 2 expected in /in/a3Nv6:7 Stack trace: #0 /in/a3Nv6(39): encrypt_base64_urlenc('this is a secre...') #1 {main} thrown in /in/a3Nv6 on line 7
Process exited with code 255.
Output for 7.0.6 - 7.0.14
Notice: Use of undefined constant MCRYPT_RIJNDAEL_256 - assumed 'MCRYPT_RIJNDAEL_256' in /in/a3Nv6 on line 4 Notice: Use of undefined constant MCRYPT_MODE_ECB - assumed 'MCRYPT_MODE_ECB' in /in/a3Nv6 on line 5 Warning: Missing argument 2 for encrypt_base64_urlenc(), called in /in/a3Nv6 on line 39 and defined in /in/a3Nv6 on line 7 Fatal error: Uncaught Error: Call to undefined function mcrypt_decrypt() in /in/a3Nv6:8 Stack trace: #0 /in/a3Nv6(39): encrypt_base64_urlenc('this is a secre...') #1 {main} thrown in /in/a3Nv6 on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.5
Warning: Missing argument 2 for encrypt_base64_urlenc(), called in /in/a3Nv6 on line 39 and defined in /in/a3Nv6 on line 7 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 8 Notice: Undefined variable: shared in /in/a3Nv6 on line 8 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 8 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 8 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 8 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 8 Warning: mcrypt_create_iv(): Cannot create an IV with a size of less than 1 or greater than 2147483647 in /in/a3Nv6 on line 8 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 19 Warning: Missing argument 2 for decrypt_base64_urlenc(), called in /in/a3Nv6 on line 40 and defined in /in/a3Nv6 on line 23 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 24 Notice: Undefined variable: shared in /in/a3Nv6 on line 24 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 24 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 24 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 24 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 24 Warning: mcrypt_create_iv(): Cannot create an IV with a size of less than 1 or greater than 2147483647 in /in/a3Nv6 on line 24 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 35
Output for hhvm-3.12.0
Warning: encrypt_base64_urlenc() expects exactly 2 parameters, 1 given in /in/a3Nv6 on line 20 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 20 Notice: Undefined variable: shared in /in/a3Nv6 on line 20 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 20 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 17 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 17 Warning: mcrypt_get_iv_size() expects parameter 1 to be string, null given in /in/a3Nv6 on line 17 Warning: mcrypt_create_iv() expects parameter 1 to be integer, null given in /in/a3Nv6 on line 20 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 20 Warning: rtrim() expects parameter 1 to be string, null given in /in/a3Nv6 on line 20 Warning: base64_decode() expects parameter 1 to be string, null given in /in/a3Nv6 on line 20 Warning: urldecode() expects parameter 1 to be string, null given in /in/a3Nv6 on line 20 Warning: decrypt_base64_urlenc() expects exactly 2 parameters, 1 given in /in/a3Nv6 on line 36 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 36 Notice: Undefined variable: shared in /in/a3Nv6 on line 36 Warning: urldecode() expects parameter 1 to be string, null given in /in/a3Nv6 on line 27
Output for hhvm-3.10.0
Warning: encrypt_base64_urlenc() expects exactly 2 parameters, 1 given in /in/a3Nv6 on line 20 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 20 Notice: Undefined variable: shared in /in/a3Nv6 on line 20 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 20 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 17 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 17 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 17 Warning: Can not create an IV with a size of less than 1 or greater than 2147483647 in /in/a3Nv6 on line 20 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 20 Warning: decrypt_base64_urlenc() expects exactly 2 parameters, 1 given in /in/a3Nv6 on line 36 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 36 Notice: Undefined variable: shared in /in/a3Nv6 on line 36 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 36 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 33 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 33 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 33
Output for 5.1.2 - 5.3.29, 5.5.35 - 5.5.38, 5.6.21 - 5.6.28
Notice: Use of undefined constant MCRYPT_RIJNDAEL_256 - assumed 'MCRYPT_RIJNDAEL_256' in /in/a3Nv6 on line 4 Notice: Use of undefined constant MCRYPT_MODE_ECB - assumed 'MCRYPT_MODE_ECB' in /in/a3Nv6 on line 5 Warning: Missing argument 2 for encrypt_base64_urlenc(), called in /in/a3Nv6 on line 39 and defined in /in/a3Nv6 on line 7 Fatal error: Call to undefined function mcrypt_decrypt() in /in/a3Nv6 on line 8
Process exited with code 255.
Output for 5.4.0 - 5.5.34, 5.6.0 - 5.6.20
Warning: Missing argument 2 for encrypt_base64_urlenc(), called in /in/a3Nv6 on line 39 and defined in /in/a3Nv6 on line 7 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 9 Notice: Undefined variable: shared in /in/a3Nv6 on line 10 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 12 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 15 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 17 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 17 Warning: mcrypt_create_iv(): Cannot create an IV with a size of less than 1 or greater than 2147483647 in /in/a3Nv6 on line 18 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 20 Warning: Missing argument 2 for decrypt_base64_urlenc(), called in /in/a3Nv6 on line 40 and defined in /in/a3Nv6 on line 23 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 25 Notice: Undefined variable: shared in /in/a3Nv6 on line 26 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 28 Notice: Undefined variable: encAlgo in /in/a3Nv6 on line 31 Notice: Undefined variable: mcryptMode in /in/a3Nv6 on line 33 Warning: mcrypt_get_iv_size(): Module initialization failed in /in/a3Nv6 on line 33 Warning: mcrypt_create_iv(): Cannot create an IV with a size of less than 1 or greater than 2147483647 in /in/a3Nv6 on line 34 Warning: mcrypt_decrypt() expects at most 5 parameters, 6 given in /in/a3Nv6 on line 36
Output for 5.0.0 - 5.1.1
Fatal error: Call to undefined function hash() in /in/a3Nv6 on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: hash() in /in/a3Nv6 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: hash() in /in/a3Nv6 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: hash() in /in/a3Nv6 on line 3