3v4l.org

run code in 300+ PHP versions simultaneously
<?php // ------- INPUT DATA PART --------- $secured_server_seed = ''; // Input the server seed if you want to validate it $server_seed = ''; $client_seed = ''; $nonce = 0; $roll = 0; // ------- INPUT DATA PART END --------- if (!empty($secured_server_seed)) { $hash_seed = hash('sha256', $server_seed); echo "Server seed: " . (strtolower($secured_server_seed) === strtolower($hash_seed) ? 'valid' : 'invalid') . "\n"; } $game_hash = hash_hmac('sha512', $server_seed, $client_seed . '-' . $nonce); $roll_game = 1 + hexdec(substr($game_hash, 0, 7)) % 10000000; echo "Roll value for \"$nonce\" nonce: $roll_game\n"; echo "Roll is " . ($roll_game === $roll ? 'valid' : 'invalid') . "\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 56
Branch analysis from position: 54
Branch analysis from position: 56
Branch analysis from position: 27
filename:       /in/KZ7sD
function name:  (null)
number of ops:  61
compiled vars:  !0 = $secured_server_seed, !1 = $server_seed, !2 = $client_seed, !3 = $nonce, !4 = $roll, !5 = $hash_seed, !6 = $game_hash, !7 = $roll_game
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, ''
    4     1        ASSIGN                                                   !1, ''
    5     2        ASSIGN                                                   !2, ''
    6     3        ASSIGN                                                   !3, 0
    7     4        ASSIGN                                                   !4, 0
    9     5        ISSET_ISEMPTY_CV                                 ~13     !0
          6        BOOL_NOT                                         ~14     ~13
          7      > JMPZ                                                     ~14, ->27
   10     8    >   INIT_FCALL                                               'hash'
          9        SEND_VAL                                                 'sha256'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $15     
         12        ASSIGN                                                   !5, $15
   11    13        INIT_FCALL                                               'strtolower'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $17     
         16        INIT_FCALL                                               'strtolower'
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $18     
         19        IS_IDENTICAL                                             $17, $18
         20      > JMPZ                                                     ~19, ->23
         21    >   QM_ASSIGN                                        ~20     'valid'
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~20     'invalid'
         24    >   CONCAT                                           ~21     'Server+seed%3A+', ~20
         25        CONCAT                                           ~22     ~21, '%0A'
         26        ECHO                                                     ~22
   13    27    >   INIT_FCALL                                               'hash_hmac'
         28        SEND_VAL                                                 'sha512'
         29        SEND_VAR                                                 !1
         30        CONCAT                                           ~23     !2, '-'
         31        CONCAT                                           ~24     ~23, !3
         32        SEND_VAL                                                 ~24
         33        DO_ICALL                                         $25     
         34        ASSIGN                                                   !6, $25
   14    35        INIT_FCALL                                               'hexdec'
         36        INIT_FCALL                                               'substr'
         37        SEND_VAR                                                 !6
         38        SEND_VAL                                                 0
         39        SEND_VAL                                                 7
         40        DO_ICALL                                         $27     
         41        SEND_VAR                                                 $27
         42        DO_ICALL                                         $28     
         43        MOD                                              ~29     $28, 10000000
         44        ADD                                              ~30     1, ~29
         45        ASSIGN                                                   !7, ~30
   15    46        ROPE_INIT                                     5  ~33     'Roll+value+for+%22'
         47        ROPE_ADD                                      1  ~33     ~33, !3
         48        ROPE_ADD                                      2  ~33     ~33, '%22+nonce%3A+'
         49        ROPE_ADD                                      3  ~33     ~33, !7
         50        ROPE_END                                      4  ~32     ~33, '%0A'
         51        ECHO                                                     ~32
   16    52        IS_IDENTICAL                                             !7, !4
         53      > JMPZ                                                     ~36, ->56
         54    >   QM_ASSIGN                                        ~37     'valid'
         55      > JMP                                                      ->57
         56    >   QM_ASSIGN                                        ~37     'invalid'
         57    >   CONCAT                                           ~38     'Roll+is+', ~37
         58        CONCAT                                           ~39     ~38, '%0A'
         59        ECHO                                                     ~39
         60      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.63 ms | 1400 KiB | 23 Q