3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Encryption { var $skey = 'SuPerEncKey2010'; // you can change it public function safe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array('+','/','='),array('-','_',''),$data); return $data; } public function safe_b64decode($string) { $data = str_replace(array('-','_'),array('+','/'),$string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); } public function encode($value){ if(!$value){return false;} $text = $value; $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->skey, $text, MCRYPT_MODE_ECB, $iv); return trim($this->safe_b64encode($crypttext)); } public function decode($value){ if(!$value){return false;} $crypttext = $this->safe_b64decode($value); $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $decrypttext = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->skey, $crypttext, MCRYPT_MODE_ECB, $iv); return trim($decrypttext); } }; encrypt->encode('wong pinter');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/375sl
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   FETCH_CONSTANT                                   ~0      'encrypt'
          1        INIT_METHOD_CALL                                         ~0, 'encode'
          2        SEND_VAL_EX                                              'wong+pinter'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class Encryption:
Function safe_b64encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/375sl
function name:  safe_b64encode
number of ops:  13
compiled vars:  !0 = $string, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'base64_encode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    9     5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 <array>
          7        SEND_VAL                                                 <array>
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $4      
         10        ASSIGN                                                   !1, $4
   10    11      > RETURN                                                   !1
   11    12*     > RETURN                                                   null

End of function safe_b64encode

Function safe_b64decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/375sl
function name:  safe_b64decode
number of ops:  21
compiled vars:  !0 = $string, !1 = $data, !2 = $mod4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   15     7        STRLEN                                           ~5      !1
          8        MOD                                              ~6      ~5, 4
          9        ASSIGN                                                   !2, ~6
   16    10      > JMPZ                                                     !2, ->16
   17    11    >   INIT_FCALL                                               'substr'
         12        SEND_VAL                                                 '%3D%3D%3D%3D'
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $8      
         15        ASSIGN_OP                                     8          !1, $8
   19    16    >   INIT_FCALL                                               'base64_decode'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $10     
         19      > RETURN                                                   $10
   20    20*     > RETURN                                                   null

End of function safe_b64decode

Function encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/375sl
function name:  encode
number of ops:  38
compiled vars:  !0 = $value, !1 = $text, !2 = $iv_size, !3 = $iv, !4 = $crypttext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        BOOL_NOT                                         ~5      !0
          2      > JMPZ                                                     ~5, ->4
          3    > > RETURN                                                   <false>
   25     4    >   ASSIGN                                                   !1, !0
   26     5        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          6        FETCH_CONSTANT                                   ~7      'MCRYPT_RIJNDAEL_256'
          7        SEND_VAL_EX                                              ~7
          8        FETCH_CONSTANT                                   ~8      'MCRYPT_MODE_ECB'
          9        SEND_VAL_EX                                              ~8
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   27    12        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         13        SEND_VAR_EX                                              !2
         14        FETCH_CONSTANT                                   ~11     'MCRYPT_RAND'
         15        SEND_VAL_EX                                              ~11
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !3, $12
   28    18        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         19        FETCH_CONSTANT                                   ~14     'MCRYPT_RIJNDAEL_256'
         20        SEND_VAL_EX                                              ~14
         21        CHECK_FUNC_ARG                                           
         22        FETCH_OBJ_FUNC_ARG                               $15     'skey'
         23        SEND_FUNC_ARG                                            $15
         24        SEND_VAR_EX                                              !1
         25        FETCH_CONSTANT                                   ~16     'MCRYPT_MODE_ECB'
         26        SEND_VAL_EX                                              ~16
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0  $17     
         29        ASSIGN                                                   !4, $17
   29    30        INIT_FCALL                                               'trim'
         31        INIT_METHOD_CALL                                         'safe_b64encode'
         32        SEND_VAR_EX                                              !4
         33        DO_FCALL                                      0  $19     
         34        SEND_VAR                                                 $19
         35        DO_ICALL                                         $20     
         36      > RETURN                                                   $20
   30    37*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/375sl
function name:  decode
number of ops:  38
compiled vars:  !0 = $value, !1 = $crypttext, !2 = $iv_size, !3 = $iv, !4 = $decrypttext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   34     1        BOOL_NOT                                         ~5      !0
          2      > JMPZ                                                     ~5, ->4
          3    > > RETURN                                                   <false>
   35     4    >   INIT_METHOD_CALL                                         'safe_b64decode'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   36     8        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          9        FETCH_CONSTANT                                   ~8      'MCRYPT_RIJNDAEL_256'
         10        SEND_VAL_EX                                              ~8
         11        FETCH_CONSTANT                                   ~9      'MCRYPT_MODE_ECB'
         12        SEND_VAL_EX                                              ~9
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   37    15        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         16        SEND_VAR_EX                                              !2
         17        FETCH_CONSTANT                                   ~12     'MCRYPT_RAND'
         18        SEND_VAL_EX                                              ~12
         19        DO_FCALL                                      0  $13     
         20        ASSIGN                                                   !3, $13
   38    21        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
         22        FETCH_CONSTANT                                   ~15     'MCRYPT_RIJNDAEL_256'
         23        SEND_VAL_EX                                              ~15
         24        CHECK_FUNC_ARG                                           
         25        FETCH_OBJ_FUNC_ARG                               $16     'skey'
         26        SEND_FUNC_ARG                                            $16
         27        SEND_VAR_EX                                              !1
         28        FETCH_CONSTANT                                   ~17     'MCRYPT_MODE_ECB'
         29        SEND_VAL_EX                                              ~17
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0  $18     
         32        ASSIGN                                                   !4, $18
   39    33        INIT_FCALL                                               'trim'
         34        SEND_VAR                                                 !4
         35        DO_ICALL                                         $20     
         36      > RETURN                                                   $20
   40    37*     > RETURN                                                   null

End of function decode

End of class Encryption.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.7 ms | 1404 KiB | 23 Q