3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate_token($string) { $token_parts = array(); for ($i = 0; $i < strlen($string); $i++) { $char = $string[$i]; $md5_hash = md5($char); $ascii_value = ord($md5_hash[0]); array_push($token_parts, strval($ascii_value)); } $token = implode("-", $token_parts); return $token; } function check_token($input_token, $valid_token) { $input_token_parts = explode("-", $input_token); $valid_token_parts = explode("-", $valid_token); for ($i = 0; $i < count($input_token_parts); $i++) { if ($input_token_parts[$i] != $valid_token_parts[$i]) { echo "El carácter " . ($i + 1) . " del token es incorrecto.\n"; } } } // Tu token $input_token = '75959'; // Reemplaza esto con tu token // Calcula el token $token = calculate_token($input_token); // Token válido $valid_token = '56-101-52-51-56'; // Verifica el token check_token($token, $valid_token); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92rG3
function name:  (null)
number of ops:  11
compiled vars:  !0 = $input_token, !1 = $token, !2 = $valid_token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN                                                   !0, '75959'
   27     1        INIT_FCALL                                               'calculate_token'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   30     5        ASSIGN                                                   !2, '56-101-52-51-56'
   33     6        INIT_FCALL                                               'check_token'
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        DO_FCALL                                      0          
   34    10      > RETURN                                                   1

Function calculate_token:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 4
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 4
Branch analysis from position: 24
Branch analysis from position: 4
filename:       /in/92rG3
function name:  calculate_token
number of ops:  31
compiled vars:  !0 = $string, !1 = $token_parts, !2 = $i, !3 = $char, !4 = $md5_hash, !5 = $ascii_value, !6 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, <array>
    4     2        ASSIGN                                                   !2, 0
          3      > JMP                                                      ->21
    5     4    >   FETCH_DIM_R                                      ~9      !0, !2
          5        ASSIGN                                                   !3, ~9
    6     6        INIT_FCALL                                               'md5'
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !4, $11
    7    10        INIT_FCALL                                               'ord'
         11        FETCH_DIM_R                                      ~13     !4, 0
         12        SEND_VAL                                                 ~13
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !5, $14
    8    15        INIT_FCALL                                               'array_push'
         16        SEND_REF                                                 !1
         17        CAST                                          6  ~16     !5
         18        SEND_VAL                                                 ~16
         19        DO_ICALL                                                 
    4    20        PRE_INC                                                  !2
         21    >   STRLEN                                           ~19     !0
         22        IS_SMALLER                                               !2, ~19
         23      > JMPNZ                                                    ~20, ->4
   10    24    >   INIT_FCALL                                               'implode'
         25        SEND_VAL                                                 '-'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $21     
         28        ASSIGN                                                   !6, $21
   11    29      > RETURN                                                   !6
   12    30*     > RETURN                                                   null

End of function calculate_token

Function check_token:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
Branch analysis from position: 14
Branch analysis from position: 22
filename:       /in/92rG3
function name:  check_token
number of ops:  27
compiled vars:  !0 = $input_token, !1 = $valid_token, !2 = $input_token_parts, !3 = $valid_token_parts, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   15     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '-'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   16     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '-'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $7      
         11        ASSIGN                                                   !3, $7
   17    12        ASSIGN                                                   !4, 0
         13      > JMP                                                      ->23
   18    14    >   FETCH_DIM_R                                      ~10     !2, !4
         15        FETCH_DIM_R                                      ~11     !3, !4
         16        IS_NOT_EQUAL                                             ~10, ~11
         17      > JMPZ                                                     ~12, ->22
   19    18    >   ADD                                              ~13     !4, 1
         19        CONCAT                                           ~14     'El+car%C3%A1cter+', ~13
         20        CONCAT                                           ~15     ~14, '+del+token+es+incorrecto.%0A'
         21        ECHO                                                     ~15
   17    22    >   PRE_INC                                                  !4
         23    >   COUNT                                            ~17     !2
         24        IS_SMALLER                                               !4, ~17
         25      > JMPNZ                                                    ~18, ->14
   22    26    > > RETURN                                                   null

End of function check_token

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.63 ms | 1022 KiB | 20 Q