3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Enter your code here, enjoy! function hmac($algo,$data,$passwd){ /* md5 and sha1 only */ $algo=strtolower($algo); echo $algo; $p=array('md5'=>'greatherH32','sha1'=>'H40'); if(strlen($passwd)>64) { $passwd=pack($p[$algo],$algo($passwd)); echo 'pass greater than 64'; echo $passwd; } if(strlen($passwd)<64) { $passwd=str_pad($passwd,64,chr(0)); echo 'pass smaller than 64'; echo $passwd; } $ipad=substr($passwd,0,64) ^ str_repeat(chr(0x36),64); echo 'ipad: '.$ipad; $opad=substr($passwd,0,64) ^ str_repeat(chr(0x5C),64); echo 'opad: '.$opad; $hashedIpadData =$algo($ipad.$data); $opadPack = $opad.pack($p[$algo],$hashedIpadData); return($algo($opadPack)); } # XXX ePay.bg URL (https://devep2.datamax.bg/ep2/epay2_demo/ if POST to DEMO system) $submit_url = 'https://devep2.datamax.bg/ep2/epay2_demo/'; # XXX Secret word with which merchant make CHECKSUM on the ENCODED packet $secret = 'secret'; $min = 'D544248794'; $invoice = 1234; # XXX Invoice $sum = '22.80'; # XXX Ammount $exp_date = '01.08.2020'; # XXX Expiration date $descr = 'Test'; # XXX Description $data = <<<DATA MIN={$min} INVOICE={$invoice} AMOUNT={$sum} EXP_TIME={$exp_date} DESCR={$descr} DATA; # XXX Packet: # (MIN or EMAIL)= REQUIRED # INVOICE= REQUIRED # AMOUNT= REQUIRED # EXP_TIME= REQUIRED # DESCR= OPTIONAL $ENCODED = base64_encode($data); $CHECKSUM = hmac('sha1', $ENCODED, $secret); # XXX SHA-1 algorithm REQUIRED echo <<<HTML <HTML> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1251"> </head> <BODY TEXT=#000000 BGCOLOR=#FFFFFF> <p>{$ENCODED}</p> <p>{$CHECKSUM}</p> HTML; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/btNQl
function name:  (null)
number of ops:  35
compiled vars:  !0 = $submit_url, !1 = $secret, !2 = $min, !3 = $invoice, !4 = $sum, !5 = $exp_date, !6 = $descr, !7 = $data, !8 = $ENCODED, !9 = $CHECKSUM
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                   !0, 'https%3A%2F%2Fdevep2.datamax.bg%2Fep2%2Fepay2_demo%2F'
   39     1        ASSIGN                                                   !1, 'secret'
   41     2        ASSIGN                                                   !2, 'D544248794'
   42     3        ASSIGN                                                   !3, 1234
   43     4        ASSIGN                                                   !4, '22.80'
   44     5        ASSIGN                                                   !5, '01.08.2020'
   45     6        ASSIGN                                                   !6, 'Test'
   48     7        ROPE_INIT                                    10  ~18     'MIN%3D'
          8        ROPE_ADD                                      1  ~18     ~18, !2
          9        ROPE_ADD                                      2  ~18     ~18, '%0AINVOICE%3D'
   49    10        ROPE_ADD                                      3  ~18     ~18, !3
         11        ROPE_ADD                                      4  ~18     ~18, '%0AAMOUNT%3D'
   50    12        ROPE_ADD                                      5  ~18     ~18, !4
         13        ROPE_ADD                                      6  ~18     ~18, '%0AEXP_TIME%3D'
   51    14        ROPE_ADD                                      7  ~18     ~18, !5
         15        ROPE_ADD                                      8  ~18     ~18, '%0ADESCR%3D'
   52    16        ROPE_END                                      9  ~17     ~18, !6
   47    17        ASSIGN                                                   !7, ~17
   62    18        INIT_FCALL                                               'base64_encode'
         19        SEND_VAR                                                 !7
         20        DO_ICALL                                         $24     
         21        ASSIGN                                                   !8, $24
   63    22        INIT_FCALL                                               'hmac'
         23        SEND_VAL                                                 'sha1'
         24        SEND_VAR                                                 !8
         25        SEND_VAR                                                 !1
         26        DO_FCALL                                      0  $26     
         27        ASSIGN                                                   !9, $26
   66    28        ROPE_INIT                                     5  ~29     '%3CHTML%3E%0A%3Chead%3E%0A++++%3Cmeta+http-equiv%3D%22content-type%22+content%3D%22text%2Fhtml%3B+charset%3Dwindows-1251%22%3E%0A%3C%2Fhead%3E%0A%3CBODY+TEXT%3D%23000000+BGCOLOR%3D%23FFFFFF%3E%0A%3Cp%3E'
   71    29        ROPE_ADD                                      1  ~29     ~29, !8
         30        ROPE_ADD                                      2  ~29     ~29, '%3C%2Fp%3E%0A%3Cp%3E'
   72    31        ROPE_ADD                                      3  ~29     ~29, !9
         32        ROPE_END                                      4  ~28     ~29, '%3C%2Fp%3E'
         33        ECHO                                                     ~28
   74    34      > RETURN                                                   1

Function hmac:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 34
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 23
filename:       /in/btNQl
function name:  hmac
number of ops:  77
compiled vars:  !0 = $algo, !1 = $data, !2 = $passwd, !3 = $p, !4 = $ipad, !5 = $opad, !6 = $hashedIpadData, !7 = $opadPack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        INIT_FCALL                                               'strtolower'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !0, $8
    7     7        ECHO                                                     !0
    8     8        ASSIGN                                                   !3, <array>
   10     9        STRLEN                                           ~11     !2
         10        IS_SMALLER                                               64, ~11
         11      > JMPZ                                                     ~12, ->23
   11    12    >   INIT_FCALL                                               'pack'
         13        FETCH_DIM_R                                      ~13     !3, !0
         14        SEND_VAL                                                 ~13
         15        INIT_DYNAMIC_CALL                                        !0
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $14     
         18        SEND_VAR                                                 $14
         19        DO_ICALL                                         $15     
         20        ASSIGN                                                   !2, $15
   12    21        ECHO                                                     'pass+greater+than+64'
   13    22        ECHO                                                     !2
   16    23    >   STRLEN                                           ~17     !2
         24        IS_SMALLER                                               ~17, 64
         25      > JMPZ                                                     ~18, ->34
   18    26    >   INIT_FCALL                                               'str_pad'
         27        SEND_VAR                                                 !2
         28        SEND_VAL                                                 64
         29        SEND_VAL                                                 '%00'
         30        DO_ICALL                                         $19     
         31        ASSIGN                                                   !2, $19
   19    32        ECHO                                                     'pass+smaller+than+64'
   20    33        ECHO                                                     !2
   24    34    >   INIT_FCALL                                               'substr'
         35        SEND_VAR                                                 !2
         36        SEND_VAL                                                 0
         37        SEND_VAL                                                 64
         38        DO_ICALL                                         $21     
         39        INIT_FCALL                                               'str_repeat'
         40        SEND_VAL                                                 '6'
         41        SEND_VAL                                                 64
         42        DO_ICALL                                         $22     
         43        BW_XOR                                           ~23     $21, $22
         44        ASSIGN                                                   !4, ~23
   25    45        CONCAT                                           ~25     'ipad%3A+', !4
         46        ECHO                                                     ~25
   26    47        INIT_FCALL                                               'substr'
         48        SEND_VAR                                                 !2
         49        SEND_VAL                                                 0
         50        SEND_VAL                                                 64
         51        DO_ICALL                                         $26     
         52        INIT_FCALL                                               'str_repeat'
         53        SEND_VAL                                                 '%5C'
         54        SEND_VAL                                                 64
         55        DO_ICALL                                         $27     
         56        BW_XOR                                           ~28     $26, $27
         57        ASSIGN                                                   !5, ~28
   27    58        CONCAT                                           ~30     'opad%3A+', !5
         59        ECHO                                                     ~30
   29    60        INIT_DYNAMIC_CALL                                        !0
         61        CONCAT                                           ~31     !4, !1
         62        SEND_VAL_EX                                              ~31
         63        DO_FCALL                                      0  $32     
         64        ASSIGN                                                   !6, $32
   31    65        INIT_FCALL                                               'pack'
         66        FETCH_DIM_R                                      ~34     !3, !0
         67        SEND_VAL                                                 ~34
         68        SEND_VAR                                                 !6
         69        DO_ICALL                                         $35     
         70        CONCAT                                           ~36     !5, $35
         71        ASSIGN                                                   !7, ~36
   33    72        INIT_DYNAMIC_CALL                                        !0
         73        SEND_VAR_EX                                              !7
         74        DO_FCALL                                      0  $38     
         75      > RETURN                                                   $38
   34    76*     > RETURN                                                   null

End of function hmac

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.36 ms | 1407 KiB | 26 Q