3v4l.org

run code in 500+ 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 trim(strtr(base64_encode($text), '+/=', '-_,')); } public static function safe_decode($text) { return 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/bO2BK
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/bO2BK
function name:  safe_encode
number of ops:  9
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
   11     1        INIT_FCALL                                                   'base64_encode'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $1      
          4        FRAMELESS_ICALL_3                strtr               ~2      $1, '%2B%2F%3D'
          5        OP_DATA                                                      '-_%2C'
          6        FRAMELESS_ICALL_1                trim                ~3      ~2
          7      > RETURN                                                       ~3
   12     8*     > 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/bO2BK
function name:  safe_decode
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   16     1        INIT_FCALL                                                   'base64_decode'
          2        FRAMELESS_ICALL_3                strtr               ~1      !0, '-_%2C'
          3        OP_DATA                                                      '%2B%2F%3D'
          4        SEND_VAL                                                     ~1
          5        DO_ICALL                                             $2      
          6      > RETURN                                                       $2
   17     7*     > 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/bO2BK
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/bO2BK
function name:  decrypt
number of ops:  28
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        FRAMELESS_ICALL_1                trim                ~16     !5
         26      > RETURN                                                       ~16
   39    27*     > RETURN                                                       null

End of function decrypt

End of class MyCrypt.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
208 ms | 2714 KiB | 17 Q