3v4l.org

run code in 300+ PHP versions simultaneously
<?php $secret="rfig34r8gw4i3ve49hfvowgrv9wu3robwer"; $signed = "LgW-AUQF8gdSfmrGTb3rGUJxzH-3Lck2K0hDMO_d-Fg.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTQ1MzExNjAwMiwicGFnZSI6eyJpZCI6IjM4MTM5OTczMDgyNyIsImFkbWluIjp0cnVlLCJsaWtlZCI6dHJ1ZX0sInVzZXIiOnsiY291bnRyeSI6ImdiIiwibG9jYWxlIjoiZW5fR0IiLCJhZ2UiOnsibWluIjoyMX19fQ"; list($encoded_sig, $payload) = explode('.', $signed_request, 2); // decode the data $sig = self::base64_url_decode($encoded_sig); $data = json_decode(self::base64_url_decode($payload), true); if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') { die('Unknown algorithm. Expected HMAC-SHA256'); } // check sig $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true); if ($sig !== $expected_sig) { die('Bad Signed JSON signature!'); } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MnUIM
function name:  (null)
number of ops:  46
compiled vars:  !0 = $secret, !1 = $signed, !2 = $signed_request, !3 = $encoded_sig, !4 = $payload, !5 = $sig, !6 = $data, !7 = $expected_sig, !8 = $raw
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'rfig34r8gw4i3ve49hfvowgrv9wu3robwer'
    3     1        ASSIGN                                                   !1, 'LgW-AUQF8gdSfmrGTb3rGUJxzH-3Lck2K0hDMO_d-Fg.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImlzc3VlZF9hdCI6MTQ1MzExNjAwMiwicGFnZSI6eyJpZCI6IjM4MTM5OTczMDgyNyIsImFkbWluIjp0cnVlLCJsaWtlZCI6dHJ1ZX0sInVzZXIiOnsiY291bnRyeSI6ImdiIiwibG9jYWxlIjoiZW5fR0IiLCJhZ2UiOnsibWluIjoyMX19fQ'
    5     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        SEND_VAR                                                 !2
          5        SEND_VAL                                                 2
          6        DO_ICALL                                         $11     
          7        FETCH_LIST_R                                     $12     $11, 0
          8        ASSIGN                                                   !3, $12
          9        FETCH_LIST_R                                     $14     $11, 1
         10        ASSIGN                                                   !4, $14
         11        FREE                                                     $11
    8    12        INIT_STATIC_METHOD_CALL                                  'base64_url_decode'
         13        SEND_VAR_EX                                              !3
         14        DO_FCALL                                      0  $16     
         15        ASSIGN                                                   !5, $16
    9    16        INIT_FCALL                                               'json_decode'
         17        INIT_STATIC_METHOD_CALL                                  'base64_url_decode'
         18        SEND_VAR_EX                                              !4
         19        DO_FCALL                                      0  $18     
         20        SEND_VAR                                                 $18
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $19     
         23        ASSIGN                                                   !6, $19
   11    24        INIT_FCALL                                               'strtoupper'
         25        FETCH_DIM_R                                      ~21     !6, 'algorithm'
         26        SEND_VAL                                                 ~21
         27        DO_ICALL                                         $22     
         28        IS_NOT_IDENTICAL                                         $22, 'HMAC-SHA256'
         29      > JMPZ                                                     ~23, ->31
   12    30    > > EXIT                                                     'Unknown+algorithm.+Expected+HMAC-SHA256'
   16    31    >   INIT_FCALL                                               'hash_hmac'
         32        SEND_VAL                                                 'sha256'
         33        SEND_VAR                                                 !4
         34        SEND_VAR                                                 !0
         35        ASSIGN                                           ~24     !8, <true>
         36        SEND_VAL                                                 ~24
         37        DO_ICALL                                         $25     
         38        ASSIGN                                                   !7, $25
   17    39        IS_NOT_IDENTICAL                                         !5, !7
         40      > JMPZ                                                     ~27, ->42
   18    41    > > EXIT                                                     'Bad+Signed+JSON+signature%21'
   21    42    >   INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !6
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.77 ms | 1400 KiB | 23 Q