3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all four below and click the blue 'eval();' button. * ------------------ */ $server_seed = "204cbf2b6c7d3df52d5fce91c83ec4f1c77614df8dd3336629c7dd5bd87ec4c5"; $public_seed = "0929140631"; $round = "12158349"; /* ------------------ */ $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 if ($roll == 0) $roll_colour = 'bonus'; elseif ($roll >= 1 and $roll <= 7) $roll_colour = 'orange'; elseif ($roll >= 8 and $roll <= 14) $roll_colour = 'black'; echo("Roll: $roll\nColour: $roll_colour");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 16
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 49
2 jumps found. (Code = 46) Position 1 = 51, Position 2 = 53
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 55
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 53
Branch analysis from position: 46
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 16
Branch analysis from position: 33
Branch analysis from position: 16
filename:       /in/nWRXD
function name:  (null)
number of ops:  61
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
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, '204cbf2b6c7d3df52d5fce91c83ec4f1c77614df8dd3336629c7dd5bd87ec4c5'
    8     1        ASSIGN                                                   !1, '0929140631'
    9     2        ASSIGN                                                   !2, '12158349'
   13     3        INIT_FCALL                                               'hash_hmac'
          4        SEND_VAL                                                 'sha256'
          5        CONCAT                                           ~12     !1, '-'
          6        CONCAT                                           ~13     ~12, !2
          7        SEND_VAL                                                 ~13
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $14     
         10        ASSIGN                                                   !3, $14
   15    11        ASSIGN                                                   !4, '0'
   16    12        STRLEN                                           ~17     !3
         13        ASSIGN                                                   !5, ~17
   17    14        ASSIGN                                                   !6, 0
         15      > JMP                                                      ->31
   18    16    >   INIT_FCALL_BY_NAME                                       'bcmul'
         17        SEND_VAR_EX                                              !4
         18        SEND_VAL_EX                                              '16'
         19        DO_FCALL                                      0  $20     
         20        ASSIGN                                                   !4, $20
   19    21        INIT_FCALL_BY_NAME                                       'bcadd'
         22        SEND_VAR_EX                                              !4
         23        INIT_FCALL                                               'hexdec'
         24        FETCH_DIM_R                                      ~22     !3, !6
         25        SEND_VAL                                                 ~22
         26        DO_ICALL                                         $23     
         27        SEND_VAR_NO_REF_EX                                       $23
         28        DO_FCALL                                      0  $24     
         29        ASSIGN                                                   !4, $24
   17    30        PRE_INC                                                  !6
         31    >   IS_SMALLER                                               !6, !5
         32      > JMPNZ                                                    ~27, ->16
   23    33    >   INIT_FCALL_BY_NAME                                       'bcmod'
         34        SEND_VAR_EX                                              !4
         35        SEND_VAL_EX                                              '15'
         36        DO_FCALL                                      0  $28     
         37        ASSIGN                                                   !7, $28
   25    38        IS_EQUAL                                                 !7, 0
         39      > JMPZ                                                     ~30, ->42
         40    >   ASSIGN                                                   !8, 'bonus'
         41      > JMP                                                      ->55
   26    42    >   IS_SMALLER_OR_EQUAL                              ~32     1, !7
         43      > JMPZ_EX                                          ~32     ~32, ->46
         44    >   IS_SMALLER_OR_EQUAL                              ~33     !7, 7
         45        BOOL                                             ~32     ~33
         46    > > JMPZ                                                     ~32, ->49
         47    >   ASSIGN                                                   !8, 'orange'
         48      > JMP                                                      ->55
   27    49    >   IS_SMALLER_OR_EQUAL                              ~35     8, !7
         50      > JMPZ_EX                                          ~35     ~35, ->53
         51    >   IS_SMALLER_OR_EQUAL                              ~36     !7, 14
         52        BOOL                                             ~35     ~36
         53    > > JMPZ                                                     ~35, ->55
         54    >   ASSIGN                                                   !8, 'black'
   29    55    >   ROPE_INIT                                     4  ~39     'Roll%3A+'
         56        ROPE_ADD                                      1  ~39     ~39, !7
         57        ROPE_ADD                                      2  ~39     ~39, '%0AColour%3A+'
         58        ROPE_END                                      3  ~38     ~39, !8
         59        ECHO                                                     ~38
         60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.43 ms | 1318 KiB | 15 Q