3v4l.org

run code in 300+ PHP versions simultaneously
<?php $config = array( "digest_alg" => "sha512", "private_key_bits" => 512, "private_key_type" => OPENSSL_KEYTYPE_RSA, ); // Create the private and public key $res = openssl_pkey_new($config); // Extract the private key from $res to $privKey openssl_pkey_export($res, $privKey); // Extract the public key from $res to $pubKey $pubKey = openssl_pkey_get_details($res); $pubKey = $pubKey["key"]; $data = 'plaintext data goes here'; // Encrypt the data to $encrypted using the public key openssl_public_encrypt($data, $encrypted, $pubKey); // Decrypt the data using the private key and store the results in $decrypted openssl_private_decrypt($encrypted, $decrypted, $privKey); echo $decrypted;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VMLuf
function name:  (null)
number of ops:  32
compiled vars:  !0 = $config, !1 = $res, !2 = $privKey, !3 = $pubKey, !4 = $data, !5 = $encrypted, !6 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_ARRAY                                       ~7      'sha512', 'digest_alg'
    4     1        ADD_ARRAY_ELEMENT                                ~7      512, 'private_key_bits'
    5     2        FETCH_CONSTANT                                   ~8      'OPENSSL_KEYTYPE_RSA'
          3        ADD_ARRAY_ELEMENT                                ~7      ~8, 'private_key_type'
    2     4        ASSIGN                                                   !0, ~7
    9     5        INIT_FCALL_BY_NAME                                       'openssl_pkey_new'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !1, $10
   12     9        INIT_FCALL_BY_NAME                                       'openssl_pkey_export'
         10        SEND_VAR_EX                                              !1
         11        SEND_VAR_EX                                              !2
         12        DO_FCALL                                      0          
   15    13        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_details'
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $13     
         16        ASSIGN                                                   !3, $13
   16    17        FETCH_DIM_R                                      ~15     !3, 'key'
         18        ASSIGN                                                   !3, ~15
   18    19        ASSIGN                                                   !4, 'plaintext+data+goes+here'
   21    20        INIT_FCALL_BY_NAME                                       'openssl_public_encrypt'
         21        SEND_VAR_EX                                              !4
         22        SEND_VAR_EX                                              !5
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
   24    25        INIT_FCALL_BY_NAME                                       'openssl_private_decrypt'
         26        SEND_VAR_EX                                              !5
         27        SEND_VAR_EX                                              !6
         28        SEND_VAR_EX                                              !2
         29        DO_FCALL                                      0          
   26    30        ECHO                                                     !6
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.43 ms | 1395 KiB | 13 Q