3v4l.org

run code in 300+ PHP versions simultaneously
<?php const ENC_METHOD = 'aes-256-ctr'; const ENC_SALT = "87CD2488-180D-442B-A68A-0307DC0CAB4D"; function B2R_Encrypt($message, $key) { $key = hash("sha256", ENC_SALT + $key, FALSE); //$key = hash("sha256", ENC_SALT + $key, TRUE); echo $key; $nonceSize = openssl_cipher_iv_length(ENC_METHOD); $nonce = openssl_random_pseudo_bytes($nonceSize); $ciphertext = openssl_encrypt( $message, ENC_METHOD, $key, OPENSSL_RAW_DATA, $nonce ); $result = base64_encode($nonce.$ciphertext); echo "\r\n"; return $result; } $ToEncrypt = 'Some test string'; $encrypted = B2R_Encrypt($ToEncrypt, ''); echo $encrypted;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbhHL
function name:  (null)
number of ops:  10
compiled vars:  !0 = $ToEncrypt, !1 = $encrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CONST                                            'ENC_METHOD', 'aes-256-ctr'
    4     1        DECLARE_CONST                                            'ENC_SALT', '87CD2488-180D-442B-A68A-0307DC0CAB4D'
   30     2        ASSIGN                                                   !0, 'Some+test+string'
   32     3        INIT_FCALL                                               'b2r_encrypt'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 ''
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                                   !1, $3
   33     8        ECHO                                                     !1
          9      > RETURN                                                   1

Function b2r_encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbhHL
function name:  B2R_Encrypt
number of ops:  38
compiled vars:  !0 = $message, !1 = $key, !2 = $nonceSize, !3 = $nonce, !4 = $ciphertext, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'hash'
          3        SEND_VAL                                                 'sha256'
          4        FETCH_CONSTANT                                   ~6      'ENC_SALT'
          5        ADD                                              ~7      ~6, !1
          6        SEND_VAL                                                 ~7
          7        SEND_VAL                                                 <false>
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !1, $8
   11    10        ECHO                                                     !1
   13    11        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
         12        FETCH_CONSTANT                                   ~10     'ENC_METHOD'
         13        SEND_VAL_EX                                              ~10
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !2, $11
   14    16        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $13     
         19        ASSIGN                                                   !3, $13
   16    20        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
   17    21        SEND_VAR_EX                                              !0
   18    22        FETCH_CONSTANT                                   ~15     'ENC_METHOD'
         23        SEND_VAL_EX                                              ~15
   17    24        SEND_VAR_EX                                              !1
   20    25        FETCH_CONSTANT                                   ~16     'OPENSSL_RAW_DATA'
         26        SEND_VAL_EX                                              ~16
   17    27        SEND_VAR_EX                                              !3
   16    28        DO_FCALL                                      0  $17     
         29        ASSIGN                                                   !4, $17
   24    30        INIT_FCALL                                               'base64_encode'
         31        CONCAT                                           ~19     !3, !4
         32        SEND_VAL                                                 ~19
         33        DO_ICALL                                         $20     
         34        ASSIGN                                                   !5, $20
   26    35        ECHO                                                     '%0D%0A'
   27    36      > RETURN                                                   !5
   28    37*     > RETURN                                                   null

End of function b2r_encrypt

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.23 ms | 1013 KiB | 16 Q