3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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 = "eyJEU19NRVJDSEFOVF9VUkxLTyI6Imh0dHBzOi8vZWplbXBsby9lamVtcGxvX1VSTF9PS19LTy5waHAiLCJEU19NRVJDSEFOVF9UUkFOU0FDVElPTlRZUEUiOiIwIiwiRHNfU2lnbmF0dXJlVmVyc2lvbiI6IkhNQUNfU0hBMjU2X1YxIiwiRFNfTUVSQ0hBTlRfQ1VSUkVOQ1kiOiI5NzgiLCJEU19NRVJDSEFOVF9NRVJDSEFOVENPREUiOiI5OTkwMDg4ODEiLCJEU19NRVJDSEFOVF9URVJNSU5BTCI6Ijg3MSIsIkRTX01FUkNIQU5UX1VSTE9LIjoiaHR0cHM6Ly9lamVtcGxvL2VqZW1wbG9fVVJMX09LX0tPLnBocCIsIkRTX01FUkNIQU5UX01FUkNIQU5UVVJMIjoiaHR0cHM6Ly9lamVtcGxvL2VqZW1wbG9fVVJMX05vdGlmLnBocCIsIkRTX01FUkNIQU5UX0FNT1VOVCI6IjE0NSIsIkRTX01FUkNIQU5UX09SREVSIjoiMTQ0Mjc3MjY0NSJ9"; // Se diversifica la clave con el Número de Pedido $key = encrypt_3DES('1442772645', $key); echo $key; // MAC256 del parámetro Ds_MerchantParameters $res = mac256($ent, $key); // Se codifican los datos Base64 return encodeBase64($res); } $key = createMerchantSignature("Mk9m98IfEblmPfrpsawt7BmxObt98Jev"); echo $key ?>
based on 8rWuY
Output for 7.0.6 - 7.2.0
Fatal error: Uncaught Error: Call to undefined function mcrypt_encrypt() in /in/DcXhr:11 Stack trace: #0 /in/DcXhr(34): encrypt_3DES('1442772645', '2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #1 /in/DcXhr(42): createMerchantSignature('2Of\xF7\xC2\x1F\x11\xB9f=\xFA\xE9\xB1\xAC-...') #2 {main} thrown in /in/DcXhr on line 11
Process exited with code 255.
Output for 5.4.10 - 5.5.34, 5.6.8 - 5.6.20, 7.0.0 - 7.0.5
������B�h�%�+EPPUq8gJhJzKHHxKdtzN16BIenKv+YxoiuSgBG37LE=
Output for 5.3.20 - 5.3.29, 5.5.35, 5.6.21 - 5.6.28
Fatal error: Call to undefined function mcrypt_encrypt() in /in/DcXhr on line 11
Process exited with code 255.