3v4l.org

run code in 300+ PHP versions simultaneously
<?php $res = openssl_pkey_new([ 'digest_alg' => 'sha256', 'private_key_bite' => 2048, 'private_key_type' => OPENSSL_TYPE_RSA ]); openssl_pkey_export($res, $privateKey); $publicKey = openssl_pkey_get_details($res)['key']; $message = 'Prime Numbers Rock!'; $aesKey = random_bytes(32); $keyE = hash_hmac('sha256', 'Encryption Key', $aesKey, true); $keyA = hash_hmac('sha256', 'Authentication Key', $aesKey, true); $iv = random_bytes(12); $ciphertext = $iv . openssl_encrypt($message, 'aes-256-ctr', $keyE, OPENSSL_RAW_DATA, $iv); $mac = hash_hmac('sha256', $ciphertext, $keyA, true); $combined = $mac . $ciphertext; $rsaCipher = ''; openssl_public_encrypt($key, $rsaCihper, $publicKey, OPENSSL_PKCS1_OAEP_PADDING); $sendMe = $rsaCipher . $combined; var_dump(strlen($rsaCipher), strlen($combined), strlen($sendMe));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7f6uc
function name:  (null)
number of ops:  78
compiled vars:  !0 = $res, !1 = $privateKey, !2 = $publicKey, !3 = $message, !4 = $aesKey, !5 = $keyE, !6 = $keyA, !7 = $iv, !8 = $ciphertext, !9 = $mac, !10 = $combined, !11 = $rsaCipher, !12 = $key, !13 = $rsaCihper, !14 = $sendMe
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL_BY_NAME                                       'openssl_pkey_new'
    3     1        INIT_ARRAY                                       ~15     'sha256', 'digest_alg'
    4     2        ADD_ARRAY_ELEMENT                                ~15     2048, 'private_key_bite'
    5     3        FETCH_CONSTANT                                   ~16     'OPENSSL_TYPE_RSA'
          4        ADD_ARRAY_ELEMENT                                ~15     ~16, 'private_key_type'
          5        SEND_VAL_EX                                              ~15
          6        DO_FCALL                                      0  $17     
    2     7        ASSIGN                                                   !0, $17
    7     8        INIT_FCALL_BY_NAME                                       'openssl_pkey_export'
          9        SEND_VAR_EX                                              !0
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
    8    12        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_details'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0  $20     
         15        FETCH_DIM_R                                      ~21     $20, 'key'
         16        ASSIGN                                                   !2, ~21
   10    17        ASSIGN                                                   !3, 'Prime+Numbers+Rock%21'
   13    18        INIT_FCALL                                               'random_bytes'
         19        SEND_VAL                                                 32
         20        DO_ICALL                                         $24     
         21        ASSIGN                                                   !4, $24
   14    22        INIT_FCALL                                               'hash_hmac'
         23        SEND_VAL                                                 'sha256'
         24        SEND_VAL                                                 'Encryption+Key'
         25        SEND_VAR                                                 !4
         26        SEND_VAL                                                 <true>
         27        DO_ICALL                                         $26     
         28        ASSIGN                                                   !5, $26
   15    29        INIT_FCALL                                               'hash_hmac'
         30        SEND_VAL                                                 'sha256'
         31        SEND_VAL                                                 'Authentication+Key'
         32        SEND_VAR                                                 !4
         33        SEND_VAL                                                 <true>
         34        DO_ICALL                                         $28     
         35        ASSIGN                                                   !6, $28
   17    36        INIT_FCALL                                               'random_bytes'
         37        SEND_VAL                                                 12
         38        DO_ICALL                                         $30     
         39        ASSIGN                                                   !7, $30
   18    40        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         41        SEND_VAR_EX                                              !3
         42        SEND_VAL_EX                                              'aes-256-ctr'
         43        SEND_VAR_EX                                              !5
         44        FETCH_CONSTANT                                   ~32     'OPENSSL_RAW_DATA'
         45        SEND_VAL_EX                                              ~32
         46        SEND_VAR_EX                                              !7
         47        DO_FCALL                                      0  $33     
         48        CONCAT                                           ~34     !7, $33
         49        ASSIGN                                                   !8, ~34
   19    50        INIT_FCALL                                               'hash_hmac'
         51        SEND_VAL                                                 'sha256'
         52        SEND_VAR                                                 !8
         53        SEND_VAR                                                 !6
         54        SEND_VAL                                                 <true>
         55        DO_ICALL                                         $36     
         56        ASSIGN                                                   !9, $36
   21    57        CONCAT                                           ~38     !9, !8
         58        ASSIGN                                                   !10, ~38
   22    59        ASSIGN                                                   !11, ''
   23    60        INIT_FCALL_BY_NAME                                       'openssl_public_encrypt'
         61        SEND_VAR_EX                                              !12
         62        SEND_VAR_EX                                              !13
         63        SEND_VAR_EX                                              !2
         64        FETCH_CONSTANT                                   ~41     'OPENSSL_PKCS1_OAEP_PADDING'
         65        SEND_VAL_EX                                              ~41
         66        DO_FCALL                                      0          
   24    67        CONCAT                                           ~43     !11, !10
         68        ASSIGN                                                   !14, ~43
   26    69        INIT_FCALL                                               'var_dump'
         70        STRLEN                                           ~45     !11
         71        SEND_VAL                                                 ~45
         72        STRLEN                                           ~46     !10
         73        SEND_VAL                                                 ~46
         74        STRLEN                                           ~47     !14
         75        SEND_VAL                                                 ~47
         76        DO_ICALL                                                 
         77      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.51 ms | 1400 KiB | 19 Q