3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all four below and click the blue 'eval();' button. * ------------------ */ $server_seed = "1ffbd2da2bf119cb573f557c0eaae9e0a6f01fa1371d15c747418e4c3ca33555"; $public_seed = "1008280137"; $round = "12222894"; /* ------------------ */ 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 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
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 = 65
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
2 jumps found. (Code = 46) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 59
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 59
2 jumps found. (Code = 46) Position 1 = 61, Position 2 = 63
Branch analysis from position: 61
2 jumps found. (Code = 43) Position 1 = 64, Position 2 = 65
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
Branch analysis from position: 63
Branch analysis from position: 56
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/cHEBo
function name:  (null)
number of ops:  71
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, '1ffbd2da2bf119cb573f557c0eaae9e0a6f01fa1371d15c747418e4c3ca33555'
    8     1        ASSIGN                                                       !1, '1008280137'
    9     2        ASSIGN                                                       !2, '12222894'
   13     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
   14    11    >   ECHO                                                         'Fill+in+details'
   15    12      > RETURN                                                       null
   18    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
   20    21        ASSIGN                                                       !4, '0'
   21    22        STRLEN                                               ~20     !3
         23        ASSIGN                                                       !5, ~20
   22    24        ASSIGN                                                       !6, 0
         25      > JMP                                                          ->41
   23    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
   24    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
   22    40        PRE_INC                                                      !6
         41    >   IS_SMALLER                                                   !6, !5
         42      > JMPNZ                                                        ~30, ->26
   28    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
   30    48        IS_EQUAL                                                     !7, 0
         49      > JMPZ                                                         ~33, ->52
         50    >   ASSIGN                                                       !8, 'bonus'
         51      > JMP                                                          ->65
   31    52    >   IS_SMALLER_OR_EQUAL                                  ~35     1, !7
         53      > JMPZ_EX                                              ~35     ~35, ->56
         54    >   IS_SMALLER_OR_EQUAL                                  ~36     !7, 7
         55        BOOL                                                 ~35     ~36
         56    > > JMPZ                                                         ~35, ->59
         57    >   ASSIGN                                                       !8, 'orange'
         58      > JMP                                                          ->65
   32    59    >   IS_SMALLER_OR_EQUAL                                  ~38     8, !7
         60      > JMPZ_EX                                              ~38     ~38, ->63
         61    >   IS_SMALLER_OR_EQUAL                                  ~39     !7, 14
         62        BOOL                                                 ~38     ~39
         63    > > JMPZ                                                         ~38, ->65
         64    >   ASSIGN                                                       !8, 'black'
   34    65    >   ROPE_INIT                                         4  ~42     'Roll%3A+'
         66        ROPE_ADD                                          1  ~42     ~42, !7
         67        ROPE_ADD                                          2  ~42     ~42, '%0AColour%3A+'
         68        ROPE_END                                          3  ~41     ~42, !8
         69        ECHO                                                         ~41
         70      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.53 ms | 1322 KiB | 15 Q