3v4l.org

run code in 300+ PHP versions simultaneously
<?php function aesCtr(string $m, string $n, string $k): string { return \openssl_decrypt($m, 'aes-128-ctr', $k, OPENSSL_RAW_DATA, $n); } $messages = [ 'wGVEtlgIETc4E4SNly0b7viJAv3bpO/85lC5/XCssVnMlrPc+TxeI+Jrsl+wVwQVOKbCEw8=', '2GxE9VRBC3giH5XMiSQXvfnGAeGHBqlXABl1mHrcabUCi8PLNlZCe+K1+3M9Vvb9nJo0AjHjuYkARV9h8WRywgFg+VSWKLb0K0lg+ZBVN70sJ+GRLrB6mCUK/ZeYucA=', '1mgX9w0TFzd2Ty69vfYaKmioBx7KaZoHHuCYCOEG519T2EQs6HJMIIle' ]; $key = hash('sha256', 'spottycats', true); $nonce = str_repeat("\0", 16); // First, remove the base64 decoding: $base64decoded = [ base64_decode($messages[0]), base64_decode($messages[1]), base64_decode($messages[2]) ]; // The last 32 bytes are a HMAC. We can strip that. $stripLast32 = [ mb_substr($base64decoded[0], 0, -32, '8bit'), mb_substr($base64decoded[1], 0, -32, '8bit'), mb_substr($base64decoded[2], 0, -32, '8bit') ]; var_dump( bin2hex($stripLast32[0]), bin2hex($stripLast32[1]), bin2hex($stripLast32[2]), aesCtr($messages[0], $nonce, $key), aesCtr($messages[1], $nonce, $key), aesCtr($messages[2], $nonce, $key) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iX61P
function name:  (null)
number of ops:  92
compiled vars:  !0 = $messages, !1 = $key, !2 = $nonce, !3 = $base64decoded, !4 = $stripLast32
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'hash'
          2        SEND_VAL                                                 'sha256'
          3        SEND_VAL                                                 'spottycats'
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !1, $6
   14     7        INIT_FCALL                                               'str_repeat'
          8        SEND_VAL                                                 '%00'
          9        SEND_VAL                                                 16
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
   18    12        INIT_FCALL                                               'base64_decode'
         13        FETCH_DIM_R                                      ~10     !0, 0
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                         $11     
         16        INIT_ARRAY                                       ~12     $11
   19    17        INIT_FCALL                                               'base64_decode'
         18        FETCH_DIM_R                                      ~13     !0, 1
         19        SEND_VAL                                                 ~13
         20        DO_ICALL                                         $14     
         21        ADD_ARRAY_ELEMENT                                ~12     $14
   20    22        INIT_FCALL                                               'base64_decode'
         23        FETCH_DIM_R                                      ~15     !0, 2
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26        ADD_ARRAY_ELEMENT                                ~12     $16
   17    27        ASSIGN                                                   !3, ~12
   25    28        INIT_FCALL                                               'mb_substr'
         29        FETCH_DIM_R                                      ~18     !3, 0
         30        SEND_VAL                                                 ~18
         31        SEND_VAL                                                 0
         32        SEND_VAL                                                 -32
         33        SEND_VAL                                                 '8bit'
         34        DO_ICALL                                         $19     
         35        INIT_ARRAY                                       ~20     $19
   26    36        INIT_FCALL                                               'mb_substr'
         37        FETCH_DIM_R                                      ~21     !3, 1
         38        SEND_VAL                                                 ~21
         39        SEND_VAL                                                 0
         40        SEND_VAL                                                 -32
         41        SEND_VAL                                                 '8bit'
         42        DO_ICALL                                         $22     
         43        ADD_ARRAY_ELEMENT                                ~20     $22
   27    44        INIT_FCALL                                               'mb_substr'
         45        FETCH_DIM_R                                      ~23     !3, 2
         46        SEND_VAL                                                 ~23
         47        SEND_VAL                                                 0
         48        SEND_VAL                                                 -32
         49        SEND_VAL                                                 '8bit'
         50        DO_ICALL                                         $24     
         51        ADD_ARRAY_ELEMENT                                ~20     $24
   24    52        ASSIGN                                                   !4, ~20
   30    53        INIT_FCALL                                               'var_dump'
   31    54        INIT_FCALL                                               'bin2hex'
         55        FETCH_DIM_R                                      ~26     !4, 0
         56        SEND_VAL                                                 ~26
         57        DO_ICALL                                         $27     
         58        SEND_VAR                                                 $27
   32    59        INIT_FCALL                                               'bin2hex'
         60        FETCH_DIM_R                                      ~28     !4, 1
         61        SEND_VAL                                                 ~28
         62        DO_ICALL                                         $29     
         63        SEND_VAR                                                 $29
   33    64        INIT_FCALL                                               'bin2hex'
         65        FETCH_DIM_R                                      ~30     !4, 2
         66        SEND_VAL                                                 ~30
         67        DO_ICALL                                         $31     
         68        SEND_VAR                                                 $31
   34    69        INIT_FCALL                                               'aesctr'
         70        FETCH_DIM_R                                      ~32     !0, 0
         71        SEND_VAL                                                 ~32
         72        SEND_VAR                                                 !2
         73        SEND_VAR                                                 !1
         74        DO_FCALL                                      0  $33     
         75        SEND_VAR                                                 $33
   35    76        INIT_FCALL                                               'aesctr'
         77        FETCH_DIM_R                                      ~34     !0, 1
         78        SEND_VAL                                                 ~34
         79        SEND_VAR                                                 !2
         80        SEND_VAR                                                 !1
         81        DO_FCALL                                      0  $35     
         82        SEND_VAR                                                 $35
   36    83        INIT_FCALL                                               'aesctr'
         84        FETCH_DIM_R                                      ~36     !0, 2
         85        SEND_VAL                                                 ~36
         86        SEND_VAR                                                 !2
         87        SEND_VAR                                                 !1
         88        DO_FCALL                                      0  $37     
         89        SEND_VAR                                                 $37
         90        DO_ICALL                                                 
   37    91      > RETURN                                                   1

Function aesctr:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iX61P
function name:  aesCtr
number of ops:  15
compiled vars:  !0 = $m, !1 = $n, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'aes-128-ctr'
          6        SEND_VAR_EX                                              !2
          7        FETCH_CONSTANT                                   ~3      'OPENSSL_RAW_DATA'
          8        SEND_VAL_EX                                              ~3
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $4      
         11        VERIFY_RETURN_TYPE                                       $4
         12      > RETURN                                                   $4
    5    13*       VERIFY_RETURN_TYPE                                       
         14*     > RETURN                                                   null

End of function aesctr

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.85 ms | 1407 KiB | 28 Q