3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Main Code By: Khucing Ithem : https://www.facebook.com/backcat * Make with Class by: hrace009 **/ $data = 'Text ini akan di encrypt menggunakan openssl! dan akan di decrypt dengan openssl juga'; $secretKey = 'mykey'; class MyCrypt { public static function safe_encode ($text) { return md5(trim(strtr(base64_encode($text), '+/=', '-_,'))); } public static function safe_decode($text) { return md5(base64_decode(strtr($text, '-_,', '+/='))); } public static function encrypt($data, $secretKey) { $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('AES-256-CBC')); $cipher = openssl_encrypt($data, 'AES-256-CBC', $secretKey, 0, $iv); $safe_cipher = MyCrypt::safe_encode($cipher); $safe_iv = MyCrypt::safe_encode($iv); return $safe_cipher . '::' . $safe_iv; } public static function decrypt($encrypted, $secretKey) { $token = explode('::', $encrypted); $cipher = MyCrypt::safe_decode($token[0]); $iv = MyCrypt::safe_decode($token[1]); $plain = openssl_decrypt($cipher, 'AES-256-CBC', $secretKey, 0, $iv); return trim($plain); } } $encrypted = MyCrypt::encrypt($data, $secretKey); $decrypted = MyCrypt::decrypt($encrypted, $secretKey); var_dump('Encrypted: ' . $encrypted); var_dump('Decrypted: ' . $decrypted); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1bfq
function name:  (null)
number of ops:  21
compiled vars:  !0 = $data, !1 = $secretKey, !2 = $encrypted, !3 = $decrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, 'Text+ini+akan+di+encrypt+menggunakan+openssl%21+dan+akan+di+decrypt+dengan+openssl+juga'
    7     1        ASSIGN                                                   !1, 'mykey'
   41     2        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'encrypt'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !2, $6
   42     7        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'decrypt'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $8      
         11        ASSIGN                                                   !3, $8
   43    12        INIT_FCALL                                               'var_dump'
         13        CONCAT                                           ~10     'Encrypted%3A+', !2
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                                 
   44    16        INIT_FCALL                                               'var_dump'
         17        CONCAT                                           ~12     'Decrypted%3A+', !3
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                                 
   45    20      > RETURN                                                   1

Class MyCrypt:
Function safe_encode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1bfq
function name:  safe_encode
number of ops:  17
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_FCALL                                               'md5'
          2        INIT_FCALL                                               'trim'
          3        INIT_FCALL                                               'strtr'
          4        INIT_FCALL                                               'base64_encode'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        SEND_VAL                                                 '%2B%2F%3D'
          9        SEND_VAL                                                 '-_%2C'
         10        DO_ICALL                                         $2      
         11        SEND_VAR                                                 $2
         12        DO_ICALL                                         $3      
         13        SEND_VAR                                                 $3
         14        DO_ICALL                                         $4      
         15      > RETURN                                                   $4
   12    16*     > RETURN                                                   null

End of function safe_encode

Function safe_decode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1bfq
function name:  safe_decode
number of ops:  14
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'md5'
          2        INIT_FCALL                                               'base64_decode'
          3        INIT_FCALL                                               'strtr'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 '-_%2C'
          6        SEND_VAL                                                 '%2B%2F%3D'
          7        DO_ICALL                                         $1      
          8        SEND_VAR                                                 $1
          9        DO_ICALL                                         $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                         $3      
         12      > RETURN                                                   $3
   17    13*     > RETURN                                                   null

End of function safe_decode

Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1bfq
function name:  encrypt
number of ops:  29
compiled vars:  !0 = $data, !1 = $secretKey, !2 = $iv, !3 = $cipher, !4 = $safe_cipher, !5 = $safe_iv
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        INIT_FCALL_BY_NAME                                       'openssl_random_pseudo_bytes'
          3        INIT_FCALL_BY_NAME                                       'openssl_cipher_iv_length'
          4        SEND_VAL_EX                                              'AES-256-CBC'
          5        DO_FCALL                                      0  $6      
          6        SEND_VAR_NO_REF_EX                                       $6
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
   22     9        INIT_FCALL_BY_NAME                                       'openssl_encrypt'
         10        SEND_VAR_EX                                              !0
         11        SEND_VAL_EX                                              'AES-256-CBC'
         12        SEND_VAR_EX                                              !1
         13        SEND_VAL_EX                                              0
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !3, $9
   24    17        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'safe_encode'
         18        SEND_VAR                                                 !3
         19        DO_FCALL                                      0  $11     
         20        ASSIGN                                                   !4, $11
   25    21        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'safe_encode'
         22        SEND_VAR                                                 !2
         23        DO_FCALL                                      0  $13     
         24        ASSIGN                                                   !5, $13
   27    25        CONCAT                                           ~15     !4, '%3A%3A'
         26        CONCAT                                           ~16     ~15, !5
         27      > RETURN                                                   ~16
   28    28*     > 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/r1bfq
function name:  decrypt
number of ops:  30
compiled vars:  !0 = $encrypted, !1 = $secretKey, !2 = $token, !3 = $cipher, !4 = $iv, !5 = $plain
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '%3A%3A'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   33     7        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'safe_decode'
          8        FETCH_DIM_R                                      ~8      !2, 0
          9        SEND_VAL                                                 ~8
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !3, $9
   34    12        INIT_STATIC_METHOD_CALL                                  'MyCrypt', 'safe_decode'
         13        FETCH_DIM_R                                      ~11     !2, 1
         14        SEND_VAL                                                 ~11
         15        DO_FCALL                                      0  $12     
         16        ASSIGN                                                   !4, $12
   36    17        INIT_FCALL_BY_NAME                                       'openssl_decrypt'
         18        SEND_VAR_EX                                              !3
         19        SEND_VAL_EX                                              'AES-256-CBC'
         20        SEND_VAR_EX                                              !1
         21        SEND_VAL_EX                                              0
         22        SEND_VAR_EX                                              !4
         23        DO_FCALL                                      0  $14     
         24        ASSIGN                                                   !5, $14
   38    25        INIT_FCALL                                               'trim'
         26        SEND_VAR                                                 !5
         27        DO_ICALL                                         $16     
         28      > RETURN                                                   $16
   39    29*     > RETURN                                                   null

End of function decrypt

End of class MyCrypt.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.66 ms | 1396 KiB | 27 Q