3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mac($msg) { $key = "7h3_1337_k3y"; $nonce = "5uc3m01"; $bloc_size = 64; if(strlen($msg)==$bloc_size) { print("cas2"); $mac = $msg; } else if(strlen($msg)>$bloc_size) { print("cas3"); $mac = hash_hmac("sha512",$msg.$nonce,$key,true); } return crypt($mac,'$6$rounds=5000$OhMyG05h!'); } $lemessage="UNMESSAGEASSEZGRANDPOURTOMBERDANSLECASDUCALCULDEHASHMAPETPOUVOIRREJOURSONMACPOURTOMBERDANSLECASCRYPTODIRECT"; $mac = mac($lemessage); $valuemac=hash_hmac("sha512",$lemessage.$nonce,$key,true); $mac2=eval('return hex2bin(\$valuemac);'); $b=mac($mac2); if($mac==$b) { print("OK"); } else{ print("KO"); } print($mac); print($b);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
cas3 Warning: Undefined variable $nonce in /in/BBJ9L on line 25 Warning: Undefined variable $key in /in/BBJ9L on line 25 Deprecated: hash_hmac(): Passing null to parameter #3 ($key) of type string is deprecated in /in/BBJ9L on line 25 Parse error: syntax error, unexpected token "\" in /in/BBJ9L(29) : eval()'d code on line 1
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 cas3 Warning: Undefined variable $nonce in /in/BBJ9L on line 25 Warning: Undefined variable $key in /in/BBJ9L on line 25 Deprecated: hash_hmac(): Passing null to parameter #3 ($key) of type string is deprecated in /in/BBJ9L on line 25 Parse error: syntax error, unexpected token "\" in /in/BBJ9L(29) : eval()'d code on line 1
Process exited with code 255.
Output for 8.0.0 - 8.0.30
cas3 Warning: Undefined variable $nonce in /in/BBJ9L on line 25 Warning: Undefined variable $key in /in/BBJ9L on line 25 Parse error: syntax error, unexpected token "\" in /in/BBJ9L(29) : eval()'d code on line 1
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
cas3 Notice: Undefined variable: nonce in /in/BBJ9L on line 25 Notice: Undefined variable: key in /in/BBJ9L on line 25 Parse error: syntax error, unexpected '$valuemac' (T_VARIABLE), expecting identifier (T_STRING) in /in/BBJ9L(29) : eval()'d code on line 1
Process exited with code 255.
Output for 7.3.32 - 7.3.33
cas3 Parse error: syntax error, unexpected '$valuemac' (T_VARIABLE), expecting identifier (T_STRING) in /in/BBJ9L(29) : eval()'d code on line 1
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38
cas3 Notice: Undefined variable: nonce in /in/BBJ9L on line 25 Notice: Undefined variable: key in /in/BBJ9L on line 25 Parse error: syntax error, unexpected '$valuemac' (T_VARIABLE), expecting identifier (T_STRING) in /in/BBJ9L(29) : eval()'d code on line 1 Notice: Undefined variable: mac in /in/BBJ9L on line 19 KO$6$rounds=5000$OhMyG05h!$EVaV8jNGJn8deADd3yFF1E6Tcm1h.WDrVgwAGWzd/HMjLYAmMLNx4aPdShsP0sIpDzfLc.SHHnSoW779gxLSt0$6$rounds=5000$OhMyG05h!$dbl6sUoiavNEU9p7fZlQR5wHf7889FFmGBnT2lrna2RZv1IHq7Ws5eG4g6GVoZXi2dqATfp3eTnJbLMBxlw/Y/

preferences:
223.41 ms | 403 KiB | 293 Q