3v4l.org

run code in 300+ 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:  70
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    >   INIT_FCALL                                               'preg_replace'
         22        SEND_VAL                                                 '%2F%0D%7C%0A%2F'
         23        SEND_VAL                                                 ''
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $18     
         26        ASSIGN                                                   !1, $18
   20    27        INIT_FCALL                                               'preg_replace'
         28        SEND_VAL                                                 '%2F%0D%7C%0A%2F'
         29        SEND_VAL                                                 ''
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $20     
         32        ASSIGN                                                   !3, $20
   33    33        INIT_FCALL                                               'calculatepreresult'
         34        ROPE_INIT                                     7  ~23     !1
         35        ROPE_ADD                                      1  ~23     ~23, '-'
         36        ROPE_ADD                                      2  ~23     ~23, !3
         37        ROPE_ADD                                      3  ~23     ~23, '-'
         38        ROPE_ADD                                      4  ~23     ~23, !0
         39        ROPE_ADD                                      5  ~23     ~23, '-'
         40        ROPE_END                                      6  ~22     ~23, !2
         41        SEND_VAL                                                 ~22
         42        SEND_VAL                                                 1000
         43        DO_FCALL                                      0  $27     
         44        ASSIGN                                                   !5, $27
   34    45        INIT_FCALL                                               'hexdec'
         46        INIT_FCALL                                               'substr'
         47        INIT_FCALL                                               'bin2hex'
         48        SEND_VAR                                                 !5
         49        DO_ICALL                                         $29     
         50        SEND_VAR                                                 $29
         51        SEND_VAL                                                 0
         52        SEND_VAL                                                 8
         53        DO_ICALL                                         $30     
         54        SEND_VAR                                                 $30
         55        DO_ICALL                                         $31     
         56        ASSIGN                                                   !6, $31
   36    57        MOD                                              ~33     !6, !4
         58        ADD                                              ~34     ~33, 1
         59        ASSIGN                                                   !7, ~34
   38    60        ROPE_INIT                                     5  ~37     'Pre-Result%3A+'
         61        ROPE_ADD                                      1  ~37     ~37, !5
         62        ROPE_ADD                                      2  ~37     ~37, '+%2F+'
         63        ROPE_ADD                                      3  ~37     ~37, !6
         64        ROPE_END                                      4  ~36     ~37, '%0A'
         65        ECHO                                                     ~36
   39    66        NOP                                                      
         67        FAST_CONCAT                                      ~40     'Result%3A+', !7
         68        ECHO                                                     ~40
         69      > 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.0.0


preferences:
142.01 ms | 1013 KiB | 19 Q