3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all four below and click the blue 'eval();' button. * ------------------ */ $server_seed = ""; $public_seed = ""; $round = ""; /* ------------------ */ if ($server_seed == '' || $public_seed === "" || $round == '') { echo "Fill in details"; return; } $hash = hash_hmac('sha256', $public_seed . "-" . $round, $server_seed); $decimal_hash = '0'; $length = strlen($hash); for ($i = 0; $i < $length; $i++) { $decimal_hash = bcmul($decimal_hash, '16'); // Multiply by base 16 $decimal_hash = bcadd($decimal_hash, hexdec($hash[$i])); // Add the current digit } // Apply modulo to get the roll $roll = bcmod($decimal_hash, '15'); // Use modulo 15 to get the roll // Determine roll colour based on new logic if (in_array($roll, [0, 2, 4, 6, 9, 11, 13])) { $roll_colour = 'red'; } elseif (in_array($roll, [1, 3, 5, 8, 10, 12, 14])) { $roll_colour = 'black'; } else { $roll_colour = 'green'; } echo("Roll: $roll\nColour: $roll_colour"); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 26
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 52
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 26
Branch analysis from position: 43
Branch analysis from position: 26
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/fPMeU
function name:  (null)
number of ops:  63
compiled vars:  !0 = $server_seed, !1 = $public_seed, !2 = $round, !3 = $hash, !4 = $decimal_hash, !5 = $length, !6 = $i, !7 = $roll, !8 = $roll_colour
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                       !0, ''
    6     1        ASSIGN                                                       !1, ''
    7     2        ASSIGN                                                       !2, ''
    9     3        IS_EQUAL                                             ~12     !0, ''
          4      > JMPNZ_EX                                             ~12     ~12, ->7
          5    >   IS_IDENTICAL                                         ~13     !1, ''
          6        BOOL                                                 ~12     ~13
          7    > > JMPNZ_EX                                             ~12     ~12, ->10
          8    >   IS_EQUAL                                             ~14     !2, ''
          9        BOOL                                                 ~12     ~14
         10    > > JMPZ                                                         ~12, ->13
   10    11    >   ECHO                                                         'Fill+in+details'
   11    12      > RETURN                                                       null
   13    13    >   INIT_FCALL                                                   'hash_hmac'
         14        SEND_VAL                                                     'sha256'
         15        CONCAT                                               ~15     !1, '-'
         16        CONCAT                                               ~16     ~15, !2
         17        SEND_VAL                                                     ~16
         18        SEND_VAR                                                     !0
         19        DO_ICALL                                             $17     
         20        ASSIGN                                                       !3, $17
   14    21        ASSIGN                                                       !4, '0'
   15    22        STRLEN                                               ~20     !3
         23        ASSIGN                                                       !5, ~20
   16    24        ASSIGN                                                       !6, 0
         25      > JMP                                                          ->41
   17    26    >   INIT_FCALL_BY_NAME                                           'bcmul'
         27        SEND_VAR_EX                                                  !4
         28        SEND_VAL_EX                                                  '16'
         29        DO_FCALL                                          0  $23     
         30        ASSIGN                                                       !4, $23
   18    31        INIT_FCALL_BY_NAME                                           'bcadd'
         32        SEND_VAR_EX                                                  !4
         33        INIT_FCALL                                                   'hexdec'
         34        FETCH_DIM_R                                          ~25     !3, !6
         35        SEND_VAL                                                     ~25
         36        DO_ICALL                                             $26     
         37        SEND_VAR_NO_REF_EX                                           $26
         38        DO_FCALL                                          0  $27     
         39        ASSIGN                                                       !4, $27
   16    40        PRE_INC                                                      !6
         41    >   IS_SMALLER                                                   !6, !5
         42      > JMPNZ                                                        ~30, ->26
   21    43    >   INIT_FCALL_BY_NAME                                           'bcmod'
         44        SEND_VAR_EX                                                  !4
         45        SEND_VAL_EX                                                  '15'
         46        DO_FCALL                                          0  $31     
         47        ASSIGN                                                       !7, $31
   24    48        FRAMELESS_ICALL_2                in_array            ~33     !7, <array>
         49      > JMPZ                                                         ~33, ->52
   25    50    >   ASSIGN                                                       !8, 'red'
   24    51      > JMP                                                          ->57
   26    52    >   FRAMELESS_ICALL_2                in_array            ~35     !7, <array>
         53      > JMPZ                                                         ~35, ->56
   27    54    >   ASSIGN                                                       !8, 'black'
   26    55      > JMP                                                          ->57
   29    56    >   ASSIGN                                                       !8, 'green'
   32    57    >   ROPE_INIT                                         4  ~39     'Roll%3A+'
         58        ROPE_ADD                                          1  ~39     ~39, !7
         59        ROPE_ADD                                          2  ~39     ~39, '%0AColour%3A+'
         60        ROPE_END                                          3  ~38     ~39, !8
         61        ECHO                                                         ~38
   33    62      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.98 ms | 1341 KiB | 15 Q