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 ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  (null)
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'createmerchantsignature'
          1        SEND_VAL                                                 'Mk9m98IfEblmPfrpsawt7BmxObt98Jev'
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   43     4        ECHO                                                     !0
   46     5      > RETURN                                                   1

Function encrypt_3des:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  encrypt_3DES
number of ops:  23
compiled vars:  !0 = $message, !1 = $key, !2 = $bytes, !3 = $iv, !4 = $ciphertext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, <array>
    8     3        INIT_FCALL                                               'implode'
          4        INIT_FCALL                                               'array_map'
          5        SEND_VAL                                                 'chr'
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $6      
          8        SEND_VAR                                                 $6
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !3, $7
   11    11        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         12        FETCH_CONSTANT                                   ~9      'MCRYPT_3DES'
         13        SEND_VAL_EX                                              ~9
         14        SEND_VAR_EX                                              !1
         15        SEND_VAR_EX                                              !0
         16        FETCH_CONSTANT                                   ~10     'MCRYPT_MODE_CBC'
         17        SEND_VAL_EX                                              ~10
         18        SEND_VAR_EX                                              !3
         19        DO_FCALL                                      0  $11     
         20        ASSIGN                                                   !4, $11
   12    21      > RETURN                                                   !4
   13    22*     > RETURN                                                   null

End of function encrypt_3des

Function encodebase64:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  encodeBase64
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'base64_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   16     5      > RETURN                                                   !0
   17     6*     > RETURN                                                   null

End of function encodebase64

Function decodebase64:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  decodeBase64
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_FCALL                                               'base64_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   20     5      > RETURN                                                   !0
   21     6*     > RETURN                                                   null

End of function decodebase64

Function mac256:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  mac256
number of ops:  11
compiled vars:  !0 = $ent, !1 = $key, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        INIT_FCALL                                               'hash_hmac'
          3        SEND_VAL                                                 'sha256'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 <true>
          7        DO_ICALL                                         $3      
          8        ASSIGN                                                   !2, $3
   25     9      > RETURN                                                   !2
   26    10*     > RETURN                                                   null

End of function mac256

Function createmerchantsignature:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vXut9
function name:  createMerchantSignature
number of ops:  21
compiled vars:  !0 = $key, !1 = $ent, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        INIT_FCALL                                               'decodebase64'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !0, $3
   32     5        ASSIGN                                                   !1, ''
   34     6        INIT_FCALL                                               'encrypt_3des'
          7        SEND_VAL                                                 '1442772645'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !0, $6
   36    11        INIT_FCALL                                               'mac256'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !0
         14        DO_FCALL                                      0  $8      
         15        ASSIGN                                                   !2, $8
   38    16        INIT_FCALL                                               'encodebase64'
         17        SEND_VAR                                                 !2
         18        DO_FCALL                                      0  $10     
         19      > RETURN                                                   $10
   39    20*     > RETURN                                                   null

End of function createmerchantsignature

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.95 ms | 1398 KiB | 28 Q