3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CRYPT { public function encrypt($Str,$Key=ENCKEY) { srand(); $Str=str_pad($Str, 32-strlen($Str)); $IVSize=mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); $IV=mcrypt_create_iv($IVSize, MCRYPT_RAND); $CryptStr=mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $Key, $Str, MCRYPT_MODE_CBC, $IV); return base64_encode($IV.$CryptStr); } public function decrypt($CryptStr,$Key=ENCKEY) { if ($CryptStr!='') { $IV=substr(base64_decode($CryptStr),0,16); $CryptStr=substr(base64_decode($CryptStr),16); return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $Key, $CryptStr, MCRYPT_MODE_CBC,$IV)); } else { return ''; } } } // class ENCRYPT() $enc = new CRYPT; $s = "test"; //$s = "FGykgbMFQiTpVIRhO9HWL/wXYevfsd7ozE99pbDWge/2Fs8fQb1iqeaw3yAe+kLsmTgPUz7mo/sTfEsvEfldWEx9XU51gsM6T1othRV6rshB9ThE3BOOUKKnhqt/gYyUP6POu5HSr7Rem7TIJIEAPh4w1cTQNN2ZCXyYS4Y+C/8="; $test = $enc->encrypt($s, "w+2#)1FP&LIPTL2<8I2"); echo $test; //echo $enc->decrypt($s, "w+2#)1FP&LIPTL2<8I2");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KHqWL
function name:  (null)
number of ops:  11
compiled vars:  !0 = $enc, !1 = $s, !2 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $3      'CRYPT'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   25     3        ASSIGN                                                   !1, 'test'
   28     4        INIT_METHOD_CALL                                         !0, 'encrypt'
          5        SEND_VAR_EX                                              !1
          6        SEND_VAL_EX                                              'w%2B2%23%291FP%26LIPTL2%3C8I2'
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
   29     9        ECHO                                                     !2
   31    10      > RETURN                                                   1

Class CRYPT:
Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KHqWL
function name:  encrypt
number of ops:  40
compiled vars:  !0 = $Str, !1 = $Key, !2 = $IVSize, !3 = $IV, !4 = $CryptStr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
    5     2        INIT_FCALL                                               'srand'
          3        DO_ICALL                                                 
    6     4        INIT_FCALL                                               'str_pad'
          5        SEND_VAR                                                 !0
          6        STRLEN                                           ~6      !0
          7        SUB                                              ~7      32, ~6
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !0, $8
    7    11        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
         12        FETCH_CONSTANT                                   ~10     'MCRYPT_RIJNDAEL_128'
         13        SEND_VAL_EX                                              ~10
         14        FETCH_CONSTANT                                   ~11     'MCRYPT_MODE_CBC'
         15        SEND_VAL_EX                                              ~11
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !2, $12
    8    18        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         19        SEND_VAR_EX                                              !2
         20        FETCH_CONSTANT                                   ~14     'MCRYPT_RAND'
         21        SEND_VAL_EX                                              ~14
         22        DO_FCALL                                      0  $15     
         23        ASSIGN                                                   !3, $15
    9    24        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         25        FETCH_CONSTANT                                   ~17     'MCRYPT_RIJNDAEL_128'
         26        SEND_VAL_EX                                              ~17
         27        SEND_VAR_EX                                              !1
         28        SEND_VAR_EX                                              !0
         29        FETCH_CONSTANT                                   ~18     'MCRYPT_MODE_CBC'
         30        SEND_VAL_EX                                              ~18
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0  $19     
         33        ASSIGN                                                   !4, $19
   10    34        INIT_FCALL                                               'base64_encode'
         35        CONCAT                                           ~21     !3, !4
         36        SEND_VAL                                                 ~21
         37        DO_ICALL                                         $22     
         38      > RETURN                                                   $22
   11    39*     > RETURN                                                   null

End of function encrypt

Function decrypt:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KHqWL
function name:  decrypt
number of ops:  37
compiled vars:  !0 = $CryptStr, !1 = $Key, !2 = $IV
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
   14     2        IS_NOT_EQUAL                                             !0, ''
          3      > JMPZ                                                     ~3, ->35
   15     4    >   INIT_FCALL                                               'substr'
          5        INIT_FCALL                                               'base64_decode'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        SEND_VAL                                                 0
         10        SEND_VAL                                                 16
         11        DO_ICALL                                         $5      
         12        ASSIGN                                                   !2, $5
   16    13        INIT_FCALL                                               'substr'
         14        INIT_FCALL                                               'base64_decode'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $7      
         17        SEND_VAR                                                 $7
         18        SEND_VAL                                                 16
         19        DO_ICALL                                         $8      
         20        ASSIGN                                                   !0, $8
   17    21        INIT_FCALL                                               'trim'
         22        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
         23        FETCH_CONSTANT                                   ~10     'MCRYPT_RIJNDAEL_128'
         24        SEND_VAL_EX                                              ~10
         25        SEND_VAR_EX                                              !1
         26        SEND_VAR_EX                                              !0
         27        FETCH_CONSTANT                                   ~11     'MCRYPT_MODE_CBC'
         28        SEND_VAL_EX                                              ~11
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0  $12     
         31        SEND_VAR                                                 $12
         32        DO_ICALL                                         $13     
         33      > RETURN                                                   $13
         34*       JMP                                                      ->36
   19    35    > > RETURN                                                   ''
   21    36*     > RETURN                                                   null

End of function decrypt

End of class CRYPT.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.28 ms | 1396 KiB | 25 Q