3v4l.org

run code in 300+ PHP versions simultaneously
<?php $request = 'POST'; $url = '/'; $headers = array( 'X-Wix-Signature' => '3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik', "X-Wix-Instance-Id" => "132fc751-9325-63d3-a605-f74e0c25192a", "X-Wix-Event-Id" => "da390885-e72f-4a93-be7f-a90220bac5c7", "X-Wix-Event-Type" => "/provision/provision", "X-Wix-Timestamp" => "2013-10-23T15:39:34.462Z", "X-Wix-Application-Id" => "132fbf95-d58e-f9ed-86e8-48b76f901d91" ); //$body = "{\n\t\"instance-id\": \"1328a7fe-e451-8780-d201-0c5d9a1fc02b\"\n}"; $body = '{"instance-id":"132fc751-9325-63d3-a605-f74e0c25192a"}'; $appSecret = "97cfac6e-b061-4007-a03e-eb4bc199e620"; function concat($request, $url, $headers, $body) { // Request Method and Url separated by \n $result = trim($request); $result .= "\n"; $result .= trim($url); $result .= "\n"; // Sort Wix-* headers by key ksort($headers); // concatenate Wix-* headers (trimmed and separate by comma) $first = true; foreach ($headers as $header) { if ($header != 'X-Wix-Signature' && $first == true) { $result = $result . trim($header); $first = false; } else if ($header != 'X-Wix-Signature') { $result = $result . ',' . trim($header); } } // Add body $result = $result . "\n" . trim($body); return $result; } $concat = concat($request, $url, $headers, $body); // Encrypt with hmac and app secret $encrypted = hash_hmac('sha256', $concat, $appSecret); $base64 = base64_encode($encrypted); echo "The computed signature is : " . $base64 . "\n"; echo "The signature sent by Wix : " . $headers['X-Wix-Signature']; // { // "Host": "signature.wix.codeoasis.com", // "X-Wix-Signature": "3elavUOF0-I1_7tGz2XZKs_HSlrygsMiblpNFPKv3Ik", // "X-Wix-Instance-Id": "132fc751-9325-63d3-a605-f74e0c25192a", // "X-Wix-Event-Id": "da390885-e72f-4a93-be7f-a90220bac5c7", // "Content-Type": "application/json; charset=utf-8", // "X-Wix-Event-Type": "/provision/provision", // "X-Wix-Timestamp": "2013-10-23T15:39:34.462Z", // "X-Wix-Application-Id": "132fbf95-d58e-f9ed-86e8-48b76f901d91", // "Connection": "keep-alive", // "Accept": "*/*", // "User-Agent": "Dispatch/0.10.1", // "Content-Length": "54", // "body": // { // "instance-id":"132fc751-9325-63d3-a605-f74e0c25192a" // } // }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4e9dO
function name:  (null)
number of ops:  29
compiled vars:  !0 = $request, !1 = $url, !2 = $headers, !3 = $body, !4 = $appSecret, !5 = $concat, !6 = $encrypted, !7 = $base64
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'POST'
    3     1        ASSIGN                                                   !1, '%2F'
    4     2        ASSIGN                                                   !2, <array>
   14     3        ASSIGN                                                   !3, '%7B%22instance-id%22%3A%22132fc751-9325-63d3-a605-f74e0c25192a%22%7D'
   16     4        ASSIGN                                                   !4, '97cfac6e-b061-4007-a03e-eb4bc199e620'
   46     5        INIT_FCALL                                               'concat'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !3
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !5, $13
   49    12        INIT_FCALL                                               'hash_hmac'
         13        SEND_VAL                                                 'sha256'
         14        SEND_VAR                                                 !5
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $15     
         17        ASSIGN                                                   !6, $15
   50    18        INIT_FCALL                                               'base64_encode'
         19        SEND_VAR                                                 !6
         20        DO_ICALL                                         $17     
         21        ASSIGN                                                   !7, $17
   52    22        CONCAT                                           ~19     'The+computed+signature+is+%3A+', !7
         23        CONCAT                                           ~20     ~19, '%0A'
         24        ECHO                                                     ~20
   53    25        FETCH_DIM_R                                      ~21     !2, 'X-Wix-Signature'
         26        CONCAT                                           ~22     'The+signature+sent+by+Wix+%3A+', ~21
         27        ECHO                                                     ~22
   73    28      > RETURN                                                   1

Function concat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 41
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 41
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 40
Branch analysis from position: 24
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/4e9dO
function name:  concat
number of ops:  50
compiled vars:  !0 = $request, !1 = $url, !2 = $headers, !3 = $body, !4 = $result, !5 = $first, !6 = $header
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   21     4        INIT_FCALL                                               'trim'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !4, $7
   22     8        ASSIGN_OP                                     8          !4, '%0A'
   23     9        INIT_FCALL                                               'trim'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12        ASSIGN_OP                                     8          !4, $10
   24    13        ASSIGN_OP                                     8          !4, '%0A'
   27    14        INIT_FCALL                                               'ksort'
         15        SEND_REF                                                 !2
         16        DO_ICALL                                                 
   30    17        ASSIGN                                                   !5, <true>
   31    18      > FE_RESET_R                                       $15     !2, ->41
         19    > > FE_FETCH_R                                               $15, !6, ->41
   32    20    >   IS_NOT_EQUAL                                     ~16     !6, 'X-Wix-Signature'
         21      > JMPZ_EX                                          ~16     ~16, ->24
         22    >   BOOL                                             ~17     !5
         23        BOOL                                             ~16     ~17
         24    > > JMPZ                                                     ~16, ->32
   33    25    >   INIT_FCALL                                               'trim'
         26        SEND_VAR                                                 !6
         27        DO_ICALL                                         $18     
         28        CONCAT                                           ~19     !4, $18
         29        ASSIGN                                                   !4, ~19
   34    30        ASSIGN                                                   !5, <false>
         31      > JMP                                                      ->40
   35    32    >   IS_NOT_EQUAL                                             !6, 'X-Wix-Signature'
         33      > JMPZ                                                     ~22, ->40
   36    34    >   CONCAT                                           ~23     !4, '%2C'
         35        INIT_FCALL                                               'trim'
         36        SEND_VAR                                                 !6
         37        DO_ICALL                                         $24     
         38        CONCAT                                           ~25     ~23, $24
         39        ASSIGN                                                   !4, ~25
   31    40    > > JMP                                                      ->19
         41    >   FE_FREE                                                  $15
   41    42        CONCAT                                           ~27     !4, '%0A'
         43        INIT_FCALL                                               'trim'
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $28     
         46        CONCAT                                           ~29     ~27, $28
         47        ASSIGN                                                   !4, ~29
   43    48      > RETURN                                                   !4
   44    49*     > RETURN                                                   null

End of function concat

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.24 ms | 1407 KiB | 22 Q