3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cipher { private $securekey, $iv; function __construct($textkey) { $this->securekey = hash('sha256',$textkey,TRUE); $this->iv = mcrypt_create_iv(32); } function encrypt($input) { return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv)); } function decrypt($input) { return rtrim(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv)),"\0"); } } $cipher = new Cipher('secret passphrase'); $encryptedtext = $cipher->encrypt("hide me"); echo "->encrypt = $encryptedtext<br />"; $decryptedtext = $cipher->decrypt($encryptedtext); echo "->decrypt = $decryptedtext<br />"; var_dump($decryptedtext);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i6vFP
function name:  (null)
number of ops:  24
compiled vars:  !0 = $cipher, !1 = $encryptedtext, !2 = $decryptedtext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $3      'Cipher'
          1        SEND_VAL_EX                                              'secret+passphrase'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
   19     4        INIT_METHOD_CALL                                         !0, 'encrypt'
          5        SEND_VAL_EX                                              'hide+me'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   20     8        ROPE_INIT                                     3  ~9      '-%3Eencrypt+%3D+'
          9        ROPE_ADD                                      1  ~9      ~9, !1
         10        ROPE_END                                      2  ~8      ~9, '%3Cbr+%2F%3E'
         11        ECHO                                                     ~8
   22    12        INIT_METHOD_CALL                                         !0, 'decrypt'
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0  $11     
         15        ASSIGN                                                   !2, $11
   23    16        ROPE_INIT                                     3  ~14     '-%3Edecrypt+%3D+'
         17        ROPE_ADD                                      1  ~14     ~14, !2
         18        ROPE_END                                      2  ~13     ~14, '%3Cbr+%2F%3E'
         19        ECHO                                                     ~13
   25    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Class Cipher:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i6vFP
function name:  __construct
number of ops:  14
compiled vars:  !0 = $textkey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'hash'
          2        SEND_VAL                                                 'sha256'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $2      
          6        ASSIGN_OBJ                                               'securekey'
          7        OP_DATA                                                  $2
    7     8        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
          9        SEND_VAL_EX                                              32
         10        DO_FCALL                                      0  $4      
         11        ASSIGN_OBJ                                               'iv'
         12        OP_DATA                                                  $4
    8    13      > RETURN                                                   null

End of function __construct

Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i6vFP
function name:  encrypt
number of ops:  19
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'base64_encode'
          2        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
          3        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          4        SEND_VAL_EX                                              ~1
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $2      'securekey'
          7        SEND_FUNC_ARG                                            $2
          8        SEND_VAR_EX                                              !0
          9        FETCH_CONSTANT                                   ~3      'MCRYPT_MODE_ECB'
         10        SEND_VAL_EX                                              ~3
         11        CHECK_FUNC_ARG                                           
         12        FETCH_OBJ_FUNC_ARG                               $4      'iv'
         13        SEND_FUNC_ARG                                            $4
         14        DO_FCALL                                      0  $5      
         15        SEND_VAR                                                 $5
         16        DO_ICALL                                         $6      
         17      > RETURN                                                   $6
   11    18*     > RETURN                                                   null

End of function encrypt

Function decrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/i6vFP
function name:  decrypt
number of ops:  26
compiled vars:  !0 = $input
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'rtrim'
          2        INIT_FCALL                                               'trim'
          3        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
          4        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          5        SEND_VAL_EX                                              ~1
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $2      'securekey'
          8        SEND_FUNC_ARG                                            $2
          9        INIT_FCALL                                               'base64_decode'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $3      
         12        SEND_VAR_NO_REF_EX                                       $3
         13        FETCH_CONSTANT                                   ~4      'MCRYPT_MODE_ECB'
         14        SEND_VAL_EX                                              ~4
         15        CHECK_FUNC_ARG                                           
         16        FETCH_OBJ_FUNC_ARG                               $5      'iv'
         17        SEND_FUNC_ARG                                            $5
         18        DO_FCALL                                      0  $6      
         19        SEND_VAR                                                 $6
         20        DO_ICALL                                         $7      
         21        SEND_VAR                                                 $7
         22        SEND_VAL                                                 '%00'
         23        DO_ICALL                                         $8      
         24      > RETURN                                                   $8
   14    25*     > RETURN                                                   null

End of function decrypt

End of class Cipher.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.63 ms | 1404 KiB | 25 Q