3v4l.org

run code in 300+ 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 = 53, Position 2 = 55
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 62
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 63
Branch analysis from position: 63
Branch analysis from position: 62
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:  69
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        INIT_FCALL                                               'in_array'
         49        SEND_VAR                                                 !7
         50        SEND_VAL                                                 <array>
         51        DO_ICALL                                         $33     
         52      > JMPZ                                                     $33, ->55
   25    53    >   ASSIGN                                                   !8, 'red'
   24    54      > JMP                                                      ->63
   26    55    >   INIT_FCALL                                               'in_array'
         56        SEND_VAR                                                 !7
         57        SEND_VAL                                                 <array>
         58        DO_ICALL                                         $35     
         59      > JMPZ                                                     $35, ->62
   27    60    >   ASSIGN                                                   !8, 'black'
   26    61      > JMP                                                      ->63
   29    62    >   ASSIGN                                                   !8, 'green'
   32    63    >   ROPE_INIT                                     4  ~39     'Roll%3A+'
         64        ROPE_ADD                                      1  ~39     ~39, !7
         65        ROPE_ADD                                      2  ~39     ~39, '%0AColour%3A+'
         66        ROPE_END                                      3  ~38     ~39, !8
         67        ECHO                                                     ~38
   33    68      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.51 ms | 1020 KiB | 16 Q