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.x/7.x compability; If( phpversion() >= 7) { $bytes = random_bytes(8); $iv = (bin2hex($bytes)); } elseif( phpversion() < 7 ) { $ivLen = 16; $iv = str_repeat("\0", $ivLen); } 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 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/18v1r
function name:  (null)
number of ops:  62
compiled vars:  !0 = $dataToEncrypt, !1 = $encryptMethod, !2 = $mySecretHash, !3 = $bytes, !4 = $iv, !5 = $ivLen, !6 = $encryptedData, !7 = $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                                         $11     
          5        IS_SMALLER_OR_EQUAL                                      7, $11
          6      > JMPZ                                                     ~12, ->16
   23     7    >   INIT_FCALL                                               'random_bytes'
          8        SEND_VAL                                                 8
          9        DO_ICALL                                         $13     
         10        ASSIGN                                                   !3, $13
   24    11        INIT_FCALL                                               'bin2hex'
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $15     
         14        ASSIGN                                                   !4, $15
         15      > JMP                                                      ->33
   26    16    >   INIT_FCALL                                               'phpversion'
         17        DO_ICALL                                         $17     
         18        IS_SMALLER                                               $17, 7
         19      > JMPZ                                                     ~18, ->27
   28    20    >   ASSIGN                                                   !5, 16
   29    21        INIT_FCALL                                               'str_repeat'
         22        SEND_VAL                                                 '%00'
         23        SEND_VAR                                                 !5
         24        DO_ICALL                                         $20     
         25        ASSIGN                                                   !4, $20
         26      > JMP                                                      ->33
   32    27    >   INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         28        SEND_VAL_EX                                              16
         29        FETCH_CONSTANT                                   ~22     'MCRYPT_DEV_URANDOM'
         30        SEND_VAL_EX                                              ~22
         31        DO_FCALL                                      0  $23     
         32        ASSIGN                                                   !4, $23
   36    33    >   INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         34        SEND_VAR_EX                                              !0
         35        SEND_VAR_EX                                              !1
         36        SEND_VAR_EX                                              !2
         37        SEND_VAL_EX                                              0
         38        SEND_VAR_EX                                              !4
         39        DO_FCALL                                      0  $25     
         40        ASSIGN                                                   !6, $25
   39    41        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
         42        SEND_VAR_EX                                              !6
         43        SEND_VAR_EX                                              !1
         44        SEND_VAR_EX                                              !2
         45        SEND_VAL_EX                                              0
         46        SEND_VAR_EX                                              !4
         47        DO_FCALL                                      0  $27     
         48        ASSIGN                                                   !7, $27
   42    49        CONCAT                                           ~29     'RandomIV+%3A+', !4
         50        CONCAT                                           ~30     ~29, '%0A'
         51        ECHO                                                     ~30
   43    52        CONCAT                                           ~31     'Secret+message+%3A+', !0
         53        CONCAT                                           ~32     ~31, '%0A'
         54        ECHO                                                     ~32
   44    55        CONCAT                                           ~33     'Encrypted+message+%3A+', !6
         56        CONCAT                                           ~34     ~33, '%0A'
         57        ECHO                                                     ~34
   45    58        CONCAT                                           ~35     'Decrypted+message%3A+', !7
         59        CONCAT                                           ~36     ~35, '%5Cln'
         60        ECHO                                                     ~36
   46    61      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.45 ms | 1400 KiB | 21 Q