3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $config = array( "digest_alg" => "sha1", "private_key_bits" => 1024, "private_key_type" => OPENSSL_KEYTYPE_RSA, ); // Create the private and public key $res = openssl_pkey_new($config); $output = ''; // Create the keypair //$res=openssl_pkey_new(); // Get private key openssl_pkey_export($res, $privatekey); $privatekey_string=base64_encode($privatekey); // Get public key $publickey=openssl_pkey_get_details($res); $publickey_string=base64_encode($publickey["key"]); echo "Private Key:\n$privatekey_string<br><br>Public Key:<BR>$publickey_string\n\n"; $chunk="HelloWorld!"; //if(openssl_private_encrypt($chunk, $encrypted, $privatekey,$padding = OPENSSL_NO_PADDING)) openssl_private_encrypt($chunk, $encryptedviaprivatekey, $privatekey); echo $chunk . "->" . $encryptedviaprivatekey; echo "\n\n";
based on IubjM
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3TGkU
function name:  (null)
number of ops:  44
compiled vars:  !0 = $config, !1 = $res, !2 = $output, !3 = $privatekey, !4 = $privatekey_string, !5 = $publickey, !6 = $publickey_string, !7 = $chunk, !8 = $encryptedviaprivatekey
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   INIT_ARRAY                                       ~9      'sha1', 'digest_alg'
   4     1        ADD_ARRAY_ELEMENT                                ~9      1024, 'private_key_bits'
   5     2        FETCH_CONSTANT                                   ~10     'OPENSSL_KEYTYPE_RSA'
         3        ADD_ARRAY_ELEMENT                                ~9      ~10, 'private_key_type'
         4        ASSIGN                                                   !0, ~9
   9     5        INIT_FCALL_BY_NAME                                       'openssl_pkey_new'
         6        SEND_VAR_EX                                              !0
         7        DO_FCALL                                      0  $12     
         8        ASSIGN                                                   !1, $12
  11     9        ASSIGN                                                   !2, ''
  16    10        INIT_FCALL_BY_NAME                                       'openssl_pkey_export'
        11        SEND_VAR_EX                                              !1
        12        SEND_VAR_EX                                              !3
        13        DO_FCALL                                      0          
  17    14        INIT_FCALL                                               'base64_encode'
        15        SEND_VAR                                                 !3
        16        DO_ICALL                                         $16     
        17        ASSIGN                                                   !4, $16
  19    18        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_details'
        19        SEND_VAR_EX                                              !1
        20        DO_FCALL                                      0  $18     
        21        ASSIGN                                                   !5, $18
  20    22        INIT_FCALL                                               'base64_encode'
        23        FETCH_DIM_R                                      $20     !5, 'key'
        24        SEND_VAR                                                 $20
        25        DO_ICALL                                         $21     
        26        ASSIGN                                                   !6, $21
  22    27        ROPE_INIT                                     5  ~24     'Private+Key%3A%0A'
        28        ROPE_ADD                                      1  ~24     ~24, !4
        29        ROPE_ADD                                      2  ~24     ~24, '%3Cbr%3E%3Cbr%3EPublic+Key%3A%3CBR%3E'
        30        ROPE_ADD                                      3  ~24     ~24, !6
        31        ROPE_END                                      4  ~23     ~24, '%0A%0A'
        32        ECHO                                                     ~23
  23    33        ASSIGN                                                   !7, 'HelloWorld%21'
  26    34        INIT_FCALL_BY_NAME                                       'openssl_private_encrypt'
        35        SEND_VAR_EX                                              !7
        36        SEND_VAR_EX                                              !8
        37        SEND_VAR_EX                                              !3
        38        DO_FCALL                                      0          
  27    39        CONCAT                                           ~29     !7, '-%3E'
        40        CONCAT                                           ~30     ~29, !8
        41        ECHO                                                     ~30
  28    42        ECHO                                                     '%0A%0A'
        43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 7.3.0