3v4l.org

run code in 300+ PHP versions simultaneously
<?php function padding($msg,$nb_chars) { $charset = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'); for($cpt=0;$cpt<$nb_chars;$cpt++) { $rand = rand(0,61); print("!!!!!!!!!!!!!!!!!".$rand); $msg .= $charset[$rand]; } return $msg; } function mac($msg) { $key = "7h3_1337_k3y"; $nonce = "5uc3m01"; $bloc_size = 64; if(strlen($msg)<$bloc_size) { $msg = padding($msg,$bloc_size-strlen($msg)); $mac = $msg; } else if(strlen($msg)==$bloc_size) { $mac = $msg; } else if(strlen($msg)>$bloc_size) { $mac = hash_hmac("sha512",$msg.$nonce,$key,true); } return crypt($mac,'$6$rounds=5000$OhMyG05h!'); } $lemessage="UNMESSAGEASSEZLONGPOURTOMBERDANSLECASDUHASHMAPETREGENERERUNHASHAVECLEHASHDECETTEVALEUR"; $mac = mac($lemessage); $valuemac=hash_hmac("sha512","123456789012345678901234567890123456789012345678901234567890123455uc3m01","7h3_1337_k3y",false); print("**".strlen($valuemac)."***".$valuemac."*******"); $mac2=eval('return hex2bin("c210825a47af7f8869fb6e11adc9dd3eceb85735c47807badaff958f0af386f5e3f7e24c15034ff6dc71d117697f5853da05bb76ec7086d07f25b53f707d9477");'); $b=mac($mac2); if($mac==$b) { print("OK"); } else{ print("KO"); } print($mac); print($b);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/STFp4
function name:  (null)
number of ops:  32
compiled vars:  !0 = $lemessage, !1 = $mac, !2 = $valuemac, !3 = $mac2, !4 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, 'UNMESSAGEASSEZLONGPOURTOMBERDANSLECASDUHASHMAPETREGENERERUNHASHAVECLEHASHDECETTEVALEUR'
   41     1        INIT_FCALL                                               'mac'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $6      
          4        ASSIGN                                                   !1, $6
   43     5        INIT_FCALL                                               'hash_hmac'
          6        SEND_VAL                                                 'sha512'
          7        SEND_VAL                                                 '123456789012345678901234567890123456789012345678901234567890123455uc3m01'
          8        SEND_VAL                                                 '7h3_1337_k3y'
          9        SEND_VAL                                                 <false>
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
   44    12        STRLEN                                           ~10     !2
         13        CONCAT                                           ~11     '%2A%2A', ~10
         14        CONCAT                                           ~12     ~11, '%2A%2A%2A'
         15        CONCAT                                           ~13     ~12, !2
         16        CONCAT                                           ~14     ~13, '%2A%2A%2A%2A%2A%2A%2A'
         17        ECHO                                                     ~14
   47    18        INCLUDE_OR_EVAL                                  $15     'return+hex2bin%28%22c210825a47af7f8869fb6e11adc9dd3eceb85735c47807badaff958f0af386f5e3f7e24c15034ff6dc71d117697f5853da05bb76ec7086d07f25b53f707d9477%22%29%3B', EVAL
         19        ASSIGN                                                   !3, $15
   51    20        INIT_FCALL                                               'mac'
         21        SEND_VAR                                                 !3
         22        DO_FCALL                                      0  $17     
         23        ASSIGN                                                   !4, $17
   52    24        IS_EQUAL                                                 !1, !4
         25      > JMPZ                                                     ~19, ->28
   54    26    >   ECHO                                                     'OK'
         27      > JMP                                                      ->29
   57    28    >   ECHO                                                     'KO'
   61    29    >   ECHO                                                     !1
   62    30        ECHO                                                     !4
         31      > RETURN                                                   1

Function padding:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 5
Branch analysis from position: 17
Branch analysis from position: 5
filename:       /in/STFp4
function name:  padding
number of ops:  19
compiled vars:  !0 = $msg, !1 = $nb_chars, !2 = $charset, !3 = $cpt, !4 = $rand
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->15
    8     5    >   INIT_FCALL                                               'rand'
          6        SEND_VAL                                                 0
          7        SEND_VAL                                                 61
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !4, $7
    9    10        CONCAT                                           ~9      '%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21%21', !4
         11        ECHO                                                     ~9
   10    12        FETCH_DIM_R                                      ~10     !2, !4
         13        ASSIGN_OP                                     8          !0, ~10
    6    14        PRE_INC                                                  !3
         15    >   IS_SMALLER                                               !3, !1
         16      > JMPNZ                                                    ~13, ->5
   12    17    > > RETURN                                                   !0
   13    18*     > RETURN                                                   null

End of function padding

Function mac:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/STFp4
function name:  mac
number of ops:  38
compiled vars:  !0 = $msg, !1 = $key, !2 = $nonce, !3 = $bloc_size, !4 = $mac
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   17     1        ASSIGN                                                   !1, '7h3_1337_k3y'
   18     2        ASSIGN                                                   !2, '5uc3m01'
   19     3        ASSIGN                                                   !3, 64
   20     4        STRLEN                                           ~8      !0
          5        IS_SMALLER                                               ~8, !3
          6      > JMPZ                                                     ~9, ->16
   22     7    >   INIT_FCALL                                               'padding'
          8        SEND_VAR                                                 !0
          9        STRLEN                                           ~10     !0
         10        SUB                                              ~11     !3, ~10
         11        SEND_VAL                                                 ~11
         12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !0, $12
   23    14        ASSIGN                                                   !4, !0
         15      > JMP                                                      ->32
   25    16    >   STRLEN                                           ~15     !0
         17        IS_EQUAL                                                 !3, ~15
         18      > JMPZ                                                     ~16, ->21
   27    19    >   ASSIGN                                                   !4, !0
         20      > JMP                                                      ->32
   29    21    >   STRLEN                                           ~18     !0
         22        IS_SMALLER                                               !3, ~18
         23      > JMPZ                                                     ~19, ->32
   31    24    >   INIT_FCALL                                               'hash_hmac'
         25        SEND_VAL                                                 'sha512'
         26        CONCAT                                           ~20     !0, !2
         27        SEND_VAL                                                 ~20
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 <true>
         30        DO_ICALL                                         $21     
         31        ASSIGN                                                   !4, $21
   33    32    >   INIT_FCALL                                               'crypt'
         33        SEND_VAR                                                 !4
         34        SEND_VAL                                                 '%246%24rounds%3D5000%24OhMyG05h%21'
         35        DO_ICALL                                         $23     
         36      > RETURN                                                   $23
   34    37*     > RETURN                                                   null

End of function mac

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.05 ms | 1407 KiB | 22 Q