3v4l.org

run code in 300+ PHP versions simultaneously
<?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:<BR>$privatekey_string<br><br>Public Key:<BR>$publickey_string<BR><BR>"; $chunk="HelloWorld!"; if(openssl_private_encrypt($chunk, $encrypted, $privatekey,$padding = OPENSSL_NO_PADDING)) { die('Failed to encrypt data'); } $encrypted_string= base64_encode($encrypted); echo "Encrypted:<BR>$encrypted_string<br>";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 44
Branch analysis from position: 43
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lpU9A
function name:  (null)
number of ops:  53
compiled vars:  !0 = $config, !1 = $res, !2 = $output, !3 = $privatekey, !4 = $privatekey_string, !5 = $publickey, !6 = $publickey_string, !7 = $chunk, !8 = $encrypted, !9 = $padding, !10 = $encrypted_string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_ARRAY                                       ~11     'sha1', 'digest_alg'
    4     1        ADD_ARRAY_ELEMENT                                ~11     1024, 'private_key_bits'
    5     2        FETCH_CONSTANT                                   ~12     'OPENSSL_KEYTYPE_RSA'
          3        ADD_ARRAY_ELEMENT                                ~11     ~12, 'private_key_type'
    2     4        ASSIGN                                                   !0, ~11
    9     5        INIT_FCALL_BY_NAME                                       'openssl_pkey_new'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $14     
          8        ASSIGN                                                   !1, $14
   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                                         $18     
         17        ASSIGN                                                   !4, $18
   19    18        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_details'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0  $20     
         21        ASSIGN                                                   !5, $20
   20    22        INIT_FCALL                                               'base64_encode'
         23        FETCH_DIM_R                                      ~22     !5, 'key'
         24        SEND_VAL                                                 ~22
         25        DO_ICALL                                         $23     
         26        ASSIGN                                                   !6, $23
   22    27        ROPE_INIT                                     5  ~26     'Private+Key%3A%3CBR%3E'
         28        ROPE_ADD                                      1  ~26     ~26, !4
         29        ROPE_ADD                                      2  ~26     ~26, '%3Cbr%3E%3Cbr%3EPublic+Key%3A%3CBR%3E'
         30        ROPE_ADD                                      3  ~26     ~26, !6
         31        ROPE_END                                      4  ~25     ~26, '%3CBR%3E%3CBR%3E'
         32        ECHO                                                     ~25
   23    33        ASSIGN                                                   !7, 'HelloWorld%21'
   24    34        INIT_FCALL_BY_NAME                                       'openssl_private_encrypt'
         35        SEND_VAR_EX                                              !7
         36        SEND_VAR_EX                                              !8
         37        SEND_VAR_EX                                              !3
         38        FETCH_CONSTANT                                   ~30     'OPENSSL_NO_PADDING'
         39        ASSIGN                                           ~31     !9, ~30
         40        SEND_VAL_EX                                              ~31
         41        DO_FCALL                                      0  $32     
         42      > JMPZ                                                     $32, ->44
   26    43    > > EXIT                                                     'Failed+to+encrypt+data'
   29    44    >   INIT_FCALL                                               'base64_encode'
         45        SEND_VAR                                                 !8
         46        DO_ICALL                                         $33     
         47        ASSIGN                                                   !10, $33
   30    48        ROPE_INIT                                     3  ~36     'Encrypted%3A%3CBR%3E'
         49        ROPE_ADD                                      1  ~36     ~36, !10
         50        ROPE_END                                      2  ~35     ~36, '%3Cbr%3E'
         51        ECHO                                                     ~35
         52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.53 ms | 1400 KiB | 15 Q