3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** Name: PHP Encryption: Desc: Encrypt and Decrypt data. Version: V1.0 Date: 3/11/2017 Author: Prince Adeyemi Contact: prince@vegasnewspaper.com Facebook: fb.com/YourVegasPrince */ // Encryption setup: $dataToEncrypt = "My Secret Telegram: Hakuna matata!"; $encryptMethod = "AES-256-CBC"; $mySecretHash = "somethingRandom12!)!)I!@1U2 goes gere"; //$iv = mcrypt_create_iv(16, MCRYPT_RAND); // php versopm 5.6.0- 7.2.x compability; If( phpversion() >= 7) { $bytes = random_bytes(8); $iv = (bin2hex($bytes)); } elseif( phpversion() < 7 ) { for ($i = -1; $i <= 16; $i++) { $iv = openssl_random_pseudo_bytes($i, $cstrong); } } else { $iv = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM); } //Encrypt data: $encryptedData = openssl_encrypt($dataToEncrypt,$encryptMethod,$mySecretHash, 0, $iv); //Decrypt data: $decryptedData = openssl_decrypt($encryptedData, $encryptMethod, $mySecretHash, 0, $iv); //OUTPUT: echo ("RandomIV : " . $iv . "\n"); echo ( "Secret message : " . $dataToEncrypt ."\n" ); echo ( "Encrypted message : ". $encryptedData ."\n" ); echo ( "Decrypted message: ". $decryptedData ."\ln"); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 22
Branch analysis from position: 30
Branch analysis from position: 22
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SNiQD
function name:  (null)
number of ops:  66
compiled vars:  !0 = $dataToEncrypt, !1 = $encryptMethod, !2 = $mySecretHash, !3 = $bytes, !4 = $iv, !5 = $i, !6 = $cstrong, !7 = $encryptedData, !8 = $decryptedData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, 'My+Secret+Telegram%3A+Hakuna+matata%21'
   14     1        ASSIGN                                                   !1, 'AES-256-CBC'
   15     2        ASSIGN                                                   !2, 'somethingRandom12%21%29%21%29I%21%401U2+goes+gere'
   21     3        INIT_FCALL                                               'phpversion'
          4        DO_ICALL                                         $12     
          5        IS_SMALLER_OR_EQUAL                                      7, $12
          6      > JMPZ                                                     ~13, ->16
   23     7    >   INIT_FCALL                                               'random_bytes'
          8        SEND_VAL                                                 8
          9        DO_ICALL                                         $14     
         10        ASSIGN                                                   !3, $14
   24    11        INIT_FCALL                                               'bin2hex'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $16     
         14        ASSIGN                                                   !4, $16
         15      > JMP                                                      ->37
   26    16    >   INIT_FCALL                                               'phpversion'
         17        DO_ICALL                                         $18     
         18        IS_SMALLER                                               $18, 7
         19      > JMPZ                                                     ~19, ->31
   28    20    >   ASSIGN                                                   !5, -1
         21      > JMP                                                      ->28
   29    22    >   INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
         23        SEND_VAR_EX                                              !5
         24        SEND_VAR_EX                                              !6
         25        DO_FCALL                                      0  $21     
         26        ASSIGN                                                   !4, $21
   28    27        PRE_INC                                                  !5
         28    >   IS_SMALLER_OR_EQUAL                                      !5, 16
         29      > JMPNZ                                                    ~24, ->22
         30    > > JMP                                                      ->37
   33    31    >   INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         32        SEND_VAL_EX                                              16
         33        FETCH_CONSTANT                                   ~25     'MCRYPT_DEV_URANDOM'
         34        SEND_VAL_EX                                              ~25
         35        DO_FCALL                                      0  $26     
         36        ASSIGN                                                   !4, $26
   37    37    >   INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         38        SEND_VAR_EX                                              !0
         39        SEND_VAR_EX                                              !1
         40        SEND_VAR_EX                                              !2
         41        SEND_VAL_EX                                              0
         42        SEND_VAR_EX                                              !4
         43        DO_FCALL                                      0  $28     
         44        ASSIGN                                                   !7, $28
   40    45        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
         46        SEND_VAR_EX                                              !7
         47        SEND_VAR_EX                                              !1
         48        SEND_VAR_EX                                              !2
         49        SEND_VAL_EX                                              0
         50        SEND_VAR_EX                                              !4
         51        DO_FCALL                                      0  $30     
         52        ASSIGN                                                   !8, $30
   43    53        CONCAT                                           ~32     'RandomIV+%3A+', !4
         54        CONCAT                                           ~33     ~32, '%0A'
         55        ECHO                                                     ~33
   44    56        CONCAT                                           ~34     'Secret+message+%3A+', !0
         57        CONCAT                                           ~35     ~34, '%0A'
         58        ECHO                                                     ~35
   45    59        CONCAT                                           ~36     'Encrypted+message+%3A+', !7
         60        CONCAT                                           ~37     ~36, '%0A'
         61        ECHO                                                     ~37
   46    62        CONCAT                                           ~38     'Decrypted+message%3A+', !8
         63        CONCAT                                           ~39     ~38, '%5Cln'
         64        ECHO                                                     ~39
   47    65      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.06 ms | 1400 KiB | 19 Q