3v4l.org

run code in 500+ PHP versions simultaneously
<?php /* * Fill in all five below and click blue 'eval();' button below textarea. * * ------------------ */ $caseNumber = -1; $unhashedServerSeed = ''; $nonce = -1; $clientSeed = ''; $qty = -1; /* ------------------ */ if ($caseNumber < 0 || $unhashedServerSeed == '' || $nonce < 0 || $clientSeed == '' || $qty < 0) { echo "Fill in details"; return; } $unhashedServerSeed = preg_replace( "/\r|\n/", "", $unhashedServerSeed ); $clientSeed = preg_replace( "/\r|\n/", "", $clientSeed ); function calculatePreResult($init, $depth, $numIterations = 0, $hash = null) { if ($numIterations === $depth) { return $hash; } if ($numIterations === 0) { $hash = $init; } return calculatePreResult($init, $depth, $numIterations + 1, hash('sha256', $hash)); } $preResult = calculatePreResult("$unhashedServerSeed-$clientSeed-$caseNumber-$nonce", 1000); $preResultAsInt = hexdec(substr(bin2hex($preResult), 0, 8)); $result = ($preResultAsInt % $qty) + 1; echo "Pre-Result: $preResult / $preResultAsInt\n"; echo "Result: $result";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 15
Branch analysis from position: 12
Branch analysis from position: 9
filename:       /in/urEYG
function name:  (null)
number of ops:  61
compiled vars:  !0 = $caseNumber, !1 = $unhashedServerSeed, !2 = $nonce, !3 = $clientSeed, !4 = $qty, !5 = $preResult, !6 = $preResultAsInt, !7 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                       !0, -1
    8     1        ASSIGN                                                       !1, ''
    9     2        ASSIGN                                                       !2, -1
   10     3        ASSIGN                                                       !3, ''
   11     4        ASSIGN                                                       !4, -1
   14     5        IS_SMALLER                                           ~13     !0, 0
          6      > JMPNZ_EX                                             ~13     ~13, ->9
          7    >   IS_EQUAL                                             ~14     !1, ''
          8        BOOL                                                 ~13     ~14
          9    > > JMPNZ_EX                                             ~13     ~13, ->12
         10    >   IS_SMALLER                                           ~15     !2, 0
         11        BOOL                                                 ~13     ~15
         12    > > JMPNZ_EX                                             ~13     ~13, ->15
         13    >   IS_EQUAL                                             ~16     !3, ''
         14        BOOL                                                 ~13     ~16
         15    > > JMPNZ_EX                                             ~13     ~13, ->18
         16    >   IS_SMALLER                                           ~17     !4, 0
         17        BOOL                                                 ~13     ~17
         18    > > JMPZ                                                         ~13, ->21
   15    19    >   ECHO                                                         'Fill+in+details'
   16    20      > RETURN                                                       null
   19    21    >   FRAMELESS_ICALL_3                preg_replace        ~18     '%2F%0D%7C%0A%2F', ''
         22        OP_DATA                                                      !1
         23        ASSIGN                                                       !1, ~18
   20    24        FRAMELESS_ICALL_3                preg_replace        ~20     '%2F%0D%7C%0A%2F', ''
         25        OP_DATA                                                      !3
         26        ASSIGN                                                       !3, ~20
   33    27        INIT_FCALL                                                   'calculatepreresult'
         28        ROPE_INIT                                         7  ~23     !1
         29        ROPE_ADD                                          1  ~23     ~23, '-'
         30        ROPE_ADD                                          2  ~23     ~23, !3
         31        ROPE_ADD                                          3  ~23     ~23, '-'
         32        ROPE_ADD                                          4  ~23     ~23, !0
         33        ROPE_ADD                                          5  ~23     ~23, '-'
         34        ROPE_END                                          6  ~22     ~23, !2
         35        SEND_VAL                                                     ~22
         36        SEND_VAL                                                     1000
         37        DO_FCALL                                          0  $27     
         38        ASSIGN                                                       !5, $27
   34    39        INIT_FCALL                                                   'hexdec'
         40        INIT_FCALL                                                   'bin2hex'
         41        SEND_VAR                                                     !5
         42        DO_ICALL                                             $29     
         43        FRAMELESS_ICALL_3                substr              ~30     $29, 0
         44        OP_DATA                                                      8
         45        SEND_VAL                                                     ~30
         46        DO_ICALL                                             $31     
         47        ASSIGN                                                       !6, $31
   36    48        MOD                                                  ~33     !6, !4
         49        ADD                                                  ~34     ~33, 1
         50        ASSIGN                                                       !7, ~34
   38    51        ROPE_INIT                                         5  ~37     'Pre-Result%3A+'
         52        ROPE_ADD                                          1  ~37     ~37, !5
         53        ROPE_ADD                                          2  ~37     ~37, '+%2F+'
         54        ROPE_ADD                                          3  ~37     ~37, !6
         55        ROPE_END                                          4  ~36     ~37, '%0A'
         56        ECHO                                                         ~36
   39    57        NOP                                                          
         58        FAST_CONCAT                                          ~40     'Result%3A+', !7
         59        ECHO                                                         ~40
         60      > RETURN                                                       1

Function calculatepreresult:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/urEYG
function name:  calculatePreResult
number of ops:  23
compiled vars:  !0 = $init, !1 = $depth, !2 = $numIterations, !3 = $hash
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV_INIT                                            !2      0
          3        RECV_INIT                                            !3      null
   24     4        IS_IDENTICAL                                                 !2, !1
          5      > JMPZ                                                         ~4, ->7
   25     6    > > RETURN                                                       !3
   27     7    >   IS_IDENTICAL                                                 !2, 0
          8      > JMPZ                                                         ~5, ->10
   28     9    >   ASSIGN                                                       !3, !0
   30    10    >   INIT_FCALL_BY_NAME                                           'calculatePreResult'
         11        SEND_VAR_EX                                                  !0
         12        SEND_VAR_EX                                                  !1
         13        ADD                                                  ~7      !2, 1
         14        SEND_VAL_EX                                                  ~7
         15        INIT_FCALL                                                   'hash'
         16        SEND_VAL                                                     'sha256'
         17        SEND_VAR                                                     !3
         18        DO_ICALL                                             $8      
         19        SEND_VAR_NO_REF_EX                                           $8
         20        DO_FCALL                                          0  $9      
         21      > RETURN                                                       $9
   31    22*     > RETURN                                                       null

End of function calculatepreresult

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
195.41 ms | 2153 KiB | 17 Q