3v4l.org

run code in 300+ PHP versions simultaneously
<?php $private_key_string = <<<__EOF__ -----BEGIN RSA PRIVATE KEY----- MIIBOwIBAAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvFB/M+o6OwnHGEtz7tL1bz J3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQJAYj3oKc+Scf1cSHUuIYl5 fruFOmgN9yz21/ORGn/noQc4HS04VynMhzojs5MVIGTFVW1KTn8L4CdQ9iIHHPO4 SQIhAPkb7XKPrCif9XnJSa8l2roMzBYbUXQeeMHW46OzehGlAiEA24zJgypJ3F8t FLqRwXLH0eMr1D50vbPWcmeAWx5hjlMCIQCtPIa8jL2k4tjLgPgFHcYmbI/hL85N eoNwCgj05vOVIQIgScOUlNgpdrwXhmZkwE0TK8aanDXbvTzl6QwzSOn9NvcCIQCS zYIZywZTRueYk3YQCTX3ofnQad7M9X2802tWqm0q6A== -----END RSA PRIVATE KEY----- __EOF__; $public_key_string = <<<__EOF__ -----BEGIN PUBLIC KEY----- MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvF B/M+o6OwnHGEtz7tL1bzJ3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQ== -----END PUBLIC KEY----- __EOF__; $private_key = openssl_pkey_get_private($private_key_string); $public_key = openssl_pkey_get_public($public_key_string); if (!$private_key) { echo "Cannot get private key\n"; } if (!$public_key) { echo "Cannot get public key\n"; } $input = "abc"; echo "input: $input\n"; openssl_public_encrypt($input, $crypttext, $public_key); openssl_private_decrypt($crypttext, $decoded, $private_key); echo "encrypted: " . base64_encode($crypttext) . "\n"; echo "decrypted: $decoded\n"; $encrypted_encoded = "0aO2tBOUdXrXkASzjnYKydq+WDj6URLvBdKOhxbkXp2/kRTjOb4cGDxBURLGoJPi53rNlNsk8AVEB9e2AkWF1Q=="; $encrypted = base64_decode($encrypted_encoded); openssl_private_decrypt($encrypted, $decrypted, $private_key); echo "decrypted: $decrypted\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 16
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
Branch analysis from position: 13
filename:       /in/eqe8c
function name:  (null)
number of ops:  56
compiled vars:  !0 = $private_key_string, !1 = $public_key_string, !2 = $private_key, !3 = $public_key, !4 = $input, !5 = $crypttext, !6 = $decoded, !7 = $encrypted_encoded, !8 = $encrypted, !9 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '-----BEGIN+RSA+PRIVATE+KEY-----%0AMIIBOwIBAAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvFB%2FM%2Bo6OwnHGEtz7tL1bz%0AJ3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQJAYj3oKc%2BScf1cSHUuIYl5%0AfruFOmgN9yz21%2FORGn%2FnoQc4HS04VynMhzojs5MVIGTFVW1KTn8L4CdQ9iIHHPO4%0ASQIhAPkb7XKPrCif9XnJSa8l2roMzBYbUXQeeMHW46OzehGlAiEA24zJgypJ3F8t%0AFLqRwXLH0eMr1D50vbPWcmeAWx5hjlMCIQCtPIa8jL2k4tjLgPgFHcYmbI%2FhL85N%0AeoNwCgj05vOVIQIgScOUlNgpdrwXhmZkwE0TK8aanDXbvTzl6QwzSOn9NvcCIQCS%0AzYIZywZTRueYk3YQCTX3ofnQad7M9X2802tWqm0q6A%3D%3D%0A-----END+RSA+PRIVATE+KEY-----%0A'
   15     1        ASSIGN                                                   !1, '-----BEGIN+PUBLIC+KEY-----%0AMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANWj431rbsGw3f6rmED2gN0sKaxxDGvF%0AB%2FM%2Bo6OwnHGEtz7tL1bzJ3wUEHzUkt4EelafK7KHNfOZ45mwmeviPn8CAwEAAQ%3D%3D%0A-----END+PUBLIC+KEY-----'
   22     2        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_private'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $12     
          5        ASSIGN                                                   !2, $12
   23     6        INIT_FCALL_BY_NAME                                       'openssl_pkey_get_public'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0  $14     
          9        ASSIGN                                                   !3, $14
   25    10        BOOL_NOT                                         ~16     !2
         11      > JMPZ                                                     ~16, ->13
   26    12    >   ECHO                                                     'Cannot+get+private+key%0A'
   29    13    >   BOOL_NOT                                         ~17     !3
         14      > JMPZ                                                     ~17, ->16
   30    15    >   ECHO                                                     'Cannot+get+public+key%0A'
   33    16    >   ASSIGN                                                   !4, 'abc'
   35    17        ROPE_INIT                                     3  ~20     'input%3A+'
         18        ROPE_ADD                                      1  ~20     ~20, !4
         19        ROPE_END                                      2  ~19     ~20, '%0A'
         20        ECHO                                                     ~19
   37    21        INIT_FCALL_BY_NAME                                       'openssl_public_encrypt'
         22        SEND_VAR_EX                                              !4
         23        SEND_VAR_EX                                              !5
         24        SEND_VAR_EX                                              !3
         25        DO_FCALL                                      0          
   38    26        INIT_FCALL_BY_NAME                                       'openssl_private_decrypt'
         27        SEND_VAR_EX                                              !5
         28        SEND_VAR_EX                                              !6
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0          
   40    31        INIT_FCALL                                               'base64_encode'
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                         $24     
         34        CONCAT                                           ~25     'encrypted%3A+', $24
         35        CONCAT                                           ~26     ~25, '%0A'
         36        ECHO                                                     ~26
   41    37        ROPE_INIT                                     3  ~28     'decrypted%3A+'
         38        ROPE_ADD                                      1  ~28     ~28, !6
         39        ROPE_END                                      2  ~27     ~28, '%0A'
         40        ECHO                                                     ~27
   43    41        ASSIGN                                                   !7, '0aO2tBOUdXrXkASzjnYKydq%2BWDj6URLvBdKOhxbkXp2%2FkRTjOb4cGDxBURLGoJPi53rNlNsk8AVEB9e2AkWF1Q%3D%3D'
   44    42        INIT_FCALL                                               'base64_decode'
         43        SEND_VAR                                                 !7
         44        DO_ICALL                                         $31     
         45        ASSIGN                                                   !8, $31
   46    46        INIT_FCALL_BY_NAME                                       'openssl_private_decrypt'
         47        SEND_VAR_EX                                              !8
         48        SEND_VAR_EX                                              !9
         49        SEND_VAR_EX                                              !2
         50        DO_FCALL                                      0          
   48    51        ROPE_INIT                                     3  ~35     'decrypted%3A+'
         52        ROPE_ADD                                      1  ~35     ~35, !9
         53        ROPE_END                                      2  ~34     ~35, '%0A'
         54        ECHO                                                     ~34
         55      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.51 ms | 954 KiB | 18 Q