3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encrypt_3DES($message, $key){ // Se establece un IV por defecto $bytes = array(0,0,0,0,0,0,0,0); //byte [] IV = {0, 0, 0, 0, 0, 0, 0, 0} $iv = implode(array_map("chr", $bytes)); //PHP 4 >= 4.0.2 // Se cifra $ciphertext = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); //PHP 4 >= 4.0.2 return $ciphertext; } function encodeBase64($data){ $data = base64_encode($data); return $data; } function decodeBase64($data){ $data = base64_decode($data); return $data; } function mac256($ent,$key){ $res = hash_hmac('sha256', $ent, $key, true);//(PHP 5 >= 5.1.2) return $res; } function createMerchantSignature($key){ // Se decodifica la clave Base64 $key = decodeBase64($key); // Se genera el parámetro Ds_MerchantParameters $ent = ""; // Se diversifica la clave con el Número de Pedido $key = encrypt_3DES('1442772645', $key); // MAC256 del parámetro Ds_MerchantParameters $res = mac256($ent, $key); // Se codifican los datos Base64 return encodeBase64($res); } $key = createMerchantSignature("Mk9m98IfEblmPfrpsawt7BmxObt98Jev"); echo $key ?>
Output for 7.0.0 - 7.0.33, 7.1.0 - 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.4, 8.3.6
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/vXut9:11 Stack trace: #0 /in/vXut9(34): encrypt_3DES('1442772645', '2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #1 /in/vXut9(41): createMerchantSignature('2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #2 {main} thrown in /in/vXut9 on line 11
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 Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/vXut9:11 Stack trace: #0 /in/vXut9(34): encrypt_3DES('1442772645', '2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #1 /in/vXut9(41): createMerchantSignature('2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #2 {main} thrown in /in/vXut9 on line 11
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function mcrypt_encrypt() in /in/vXut9 on line 11
Process exited with code 255.

preferences:
233.44 ms | 402 KiB | 330 Q