3v4l.org

run code in 300+ PHP versions simultaneously
<?php $algo = 'aes-256-gcm'; $iv = random_bytes(openssl_cipher_iv_length($algo)); echo(openssl_cipher_iv_length($algo)); echo("\n"); $key = random_bytes(32); // 256 bit //$data = random_bytes(1024); // 1 Kb of random data $data = "well hello there with insane length and soooooooooooooooooooooooooooooooooooooooo much data in it. Bigger better stronger D:"; $ciphertext = openssl_encrypt( $data, $algo, $key, OPENSSL_RAW_DATA, $iv, $tag ); // Change 1 bit in ciphertext // $i = rand(0, mb_strlen($ciphertext, '8bit') - 1); // $ciphertext[$i] = $ciphertext[$i] ^ chr(1); echo(base64_encode($ciphertext)); echo("\n"); echo(base64_encode($tag)); $i = rand(0, mb_strlen($tag, '8bit') - 1); //$tag[$i] = $tag[$i] ^ chr(1); echo("\n"); echo(base64_encode($tag)); echo("\n"); echo(mb_strlen($tag, '8bit')); $decrypt = openssl_decrypt( $ciphertext, $algo, $key, OPENSSL_RAW_DATA, $iv, $tag ); if (false === $decrypt) { throw new Exception(sprintf( "OpenSSL error: %s", openssl_error_string() )); } printf ("\nDecryption %s\n", $data === $decrypt ? 'Ok' : 'Failed');
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 80
Branch analysis from position: 70
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 80
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 86
Branch analysis from position: 84
1 jumps found. (Code = 42) Position 1 = 87
Branch analysis from position: 87
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 86
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/j3le2
function name:  (null)
number of ops:  90
compiled vars:  !0 = $algo, !1 = $iv, !2 = $key, !3 = $data, !4 = $ciphertext, !5 = $tag, !6 = $i, !7 = $decrypt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'aes-256-gcm'
    3     1        INIT_FCALL                                               'random_bytes'
          2        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $9      
          5        SEND_VAR                                                 $9
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !1, $10
    5     8        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $12     
         11        ECHO                                                     $12
    6    12        ECHO                                                     '%0A'
    7    13        INIT_FCALL                                               'random_bytes'
         14        SEND_VAL                                                 32
         15        DO_ICALL                                         $13     
         16        ASSIGN                                                   !2, $13
    9    17        ASSIGN                                                   !3, 'well+hello+there+with+insane+length+and+soooooooooooooooooooooooooooooooooooooooo+much+data+in+it.+Bigger+better+stronger+D%3A'
   10    18        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
   11    19        SEND_VAR_EX                                              !3
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !2
   14    22        FETCH_CONSTANT                                   ~16     'OPENSSL_RAW_DATA'
         23        SEND_VAL_EX                                              ~16
   11    24        SEND_VAR_EX                                              !1
         25        SEND_VAR_EX                                              !5
         26        DO_FCALL                                      0  $17     
   10    27        ASSIGN                                                   !4, $17
   21    28        INIT_FCALL                                               'base64_encode'
         29        SEND_VAR                                                 !4
         30        DO_ICALL                                         $19     
         31        ECHO                                                     $19
   22    32        ECHO                                                     '%0A'
   23    33        INIT_FCALL                                               'base64_encode'
         34        SEND_VAR                                                 !5
         35        DO_ICALL                                         $20     
         36        ECHO                                                     $20
   24    37        INIT_FCALL                                               'rand'
         38        SEND_VAL                                                 0
         39        INIT_FCALL                                               'mb_strlen'
         40        SEND_VAR                                                 !5
         41        SEND_VAL                                                 '8bit'
         42        DO_ICALL                                         $21     
         43        SUB                                              ~22     $21, 1
         44        SEND_VAL                                                 ~22
         45        DO_ICALL                                         $23     
         46        ASSIGN                                                   !6, $23
   26    47        ECHO                                                     '%0A'
   27    48        INIT_FCALL                                               'base64_encode'
         49        SEND_VAR                                                 !5
         50        DO_ICALL                                         $25     
         51        ECHO                                                     $25
   28    52        ECHO                                                     '%0A'
   29    53        INIT_FCALL                                               'mb_strlen'
         54        SEND_VAR                                                 !5
         55        SEND_VAL                                                 '8bit'
         56        DO_ICALL                                         $26     
         57        ECHO                                                     $26
   30    58        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
   31    59        SEND_VAR_EX                                              !4
         60        SEND_VAR_EX                                              !0
         61        SEND_VAR_EX                                              !2
   34    62        FETCH_CONSTANT                                   ~27     'OPENSSL_RAW_DATA'
         63        SEND_VAL_EX                                              ~27
   31    64        SEND_VAR_EX                                              !1
         65        SEND_VAR_EX                                              !5
         66        DO_FCALL                                      0  $28     
   30    67        ASSIGN                                                   !7, $28
   38    68        TYPE_CHECK                                    4          !7
         69      > JMPZ                                                     ~30, ->80
   39    70    >   NEW                                              $31     'Exception'
         71        INIT_FCALL                                               'sprintf'
   40    72        SEND_VAL                                                 'OpenSSL+error%3A+%25s'
         73        INIT_FCALL_BY_NAME                                       'openssl_error_string'
         74        DO_FCALL                                      0  $32     
         75        SEND_VAR                                                 $32
         76        DO_ICALL                                         $33     
         77        SEND_VAR_NO_REF_EX                                       $33
         78        DO_FCALL                                      0          
         79      > THROW                                         0          $31
   43    80    >   INIT_FCALL                                               'printf'
         81        SEND_VAL                                                 '%0ADecryption+%25s%0A'
         82        IS_IDENTICAL                                             !3, !7
         83      > JMPZ                                                     ~35, ->86
         84    >   QM_ASSIGN                                        ~36     'Ok'
         85      > JMP                                                      ->87
         86    >   QM_ASSIGN                                        ~36     'Failed'
         87    >   SEND_VAL                                                 ~36
         88        DO_ICALL                                                 
         89      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
259.93 ms | 1404 KiB | 26 Q