3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = "wpdPVWejqNRYqDTeUJ2Iw06/rnfHAoy5jtgTojiilD0="; $pwd = "ICS2015"; $salt = "7"; $dec = Decrypt($data, $pwd, $salt); echo "Dec: " . $dec . "\r\n"; $enc = Encrypt("boy10@naver.com", $pwd, $salt); echo "Enc: " . $enc . "\r\n"; function Decrypt($ciphertext, $password, $salt) { $ciphertext = base64_decode($ciphertext); $key = PBKDF1($password, $salt, 100, 32); $iv = PBKDF1($password, $salt, 100, 16); // NB: Need 128 not 256 and CBC mode to be compatible $decpad = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext, MCRYPT_MODE_CBC, $iv); $pad = ord($decpad[($len = strlen($decpad)) - 1]); $dec = substr($decpad, 0, strlen($decpad) - $pad); return $dec; } function Encrypt($ciphertext, $password, $salt) { $key = PBKDF1($password, $salt, 1000, 32); echo "key: " . base64_encode($key) . "\r\n"; $iv = PBKDF1($password, $salt, 1000, 16); return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $ciphertext, MCRYPT_MODE_CBC, $iv)); } function PBKDF1($pass,$salt,$count,$dklen) { $t = $pass.$salt; //echo 'S||P: '.bin2hex($t).'<br/>'; $t = sha1($t, true); //echo 'T1:' . bin2hex($t) . '<br/>'; for($i=2; $i <= $count; $i++) { $t = sha1($t, true); //echo 'T'.$i.':' . bin2hex($t) . '<br/>'; } $t = substr($t,0,$dklen); return $t; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rd3r
function name:  (null)
number of ops:  22
compiled vars:  !0 = $data, !1 = $pwd, !2 = $salt, !3 = $dec, !4 = $enc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'wpdPVWejqNRYqDTeUJ2Iw06%2FrnfHAoy5jtgTojiilD0%3D'
    3     1        ASSIGN                                                   !1, 'ICS2015'
    4     2        ASSIGN                                                   !2, '7'
    8     3        INIT_FCALL_BY_NAME                                       'Decrypt'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        SEND_VAR_EX                                              !2
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !3, $8
    9     9        CONCAT                                           ~10     'Dec%3A+', !3
         10        CONCAT                                           ~11     ~10, '%0D%0A'
         11        ECHO                                                     ~11
   11    12        INIT_FCALL_BY_NAME                                       'Encrypt'
         13        SEND_VAL_EX                                              'boy10%40naver.com'
         14        SEND_VAR_EX                                              !1
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !4, $12
   12    18        CONCAT                                           ~14     'Enc%3A+', !4
         19        CONCAT                                           ~15     ~14, '%0D%0A'
         20        ECHO                                                     ~15
   55    21      > RETURN                                                   1

Function decrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rd3r
function name:  Decrypt
number of ops:  49
compiled vars:  !0 = $ciphertext, !1 = $password, !2 = $salt, !3 = $key, !4 = $iv, !5 = $decpad, !6 = $pad, !7 = $len, !8 = $dec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   18     3        INIT_FCALL                                               'base64_decode'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !0, $9
   19     7        INIT_FCALL_BY_NAME                                       'PBKDF1'
          8        SEND_VAR_EX                                              !1
          9        SEND_VAR_EX                                              !2
         10        SEND_VAL_EX                                              100
         11        SEND_VAL_EX                                              32
         12        DO_FCALL                                      0  $11     
         13        ASSIGN                                                   !3, $11
   20    14        INIT_FCALL_BY_NAME                                       'PBKDF1'
         15        SEND_VAR_EX                                              !1
         16        SEND_VAR_EX                                              !2
         17        SEND_VAL_EX                                              100
         18        SEND_VAL_EX                                              16
         19        DO_FCALL                                      0  $13     
         20        ASSIGN                                                   !4, $13
   23    21        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
         22        FETCH_CONSTANT                                   ~15     'MCRYPT_RIJNDAEL_128'
         23        SEND_VAL_EX                                              ~15
         24        SEND_VAR_EX                                              !3
         25        SEND_VAR_EX                                              !0
         26        FETCH_CONSTANT                                   ~16     'MCRYPT_MODE_CBC'
         27        SEND_VAL_EX                                              ~16
         28        SEND_VAR_EX                                              !4
         29        DO_FCALL                                      0  $17     
         30        ASSIGN                                                   !5, $17
   25    31        INIT_FCALL                                               'ord'
         32        STRLEN                                           ~19     !5
         33        ASSIGN                                           ~20     !7, ~19
         34        SUB                                              ~21     ~20, 1
         35        FETCH_DIM_R                                      ~22     !5, ~21
         36        SEND_VAL                                                 ~22
         37        DO_ICALL                                         $23     
         38        ASSIGN                                                   !6, $23
   26    39        INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !5
         41        SEND_VAL                                                 0
         42        STRLEN                                           ~25     !5
         43        SUB                                              ~26     ~25, !6
         44        SEND_VAL                                                 ~26
         45        DO_ICALL                                         $27     
         46        ASSIGN                                                   !8, $27
   28    47      > RETURN                                                   !8
   29    48*     > RETURN                                                   null

End of function decrypt

Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6rd3r
function name:  Encrypt
number of ops:  37
compiled vars:  !0 = $ciphertext, !1 = $password, !2 = $salt, !3 = $key, !4 = $iv
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   35     3        INIT_FCALL_BY_NAME                                       'PBKDF1'
          4        SEND_VAR_EX                                              !1
          5        SEND_VAR_EX                                              !2
          6        SEND_VAL_EX                                              1000
          7        SEND_VAL_EX                                              32
          8        DO_FCALL                                      0  $5      
          9        ASSIGN                                                   !3, $5
   36    10        INIT_FCALL                                               'base64_encode'
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $7      
         13        CONCAT                                           ~8      'key%3A+', $7
         14        CONCAT                                           ~9      ~8, '%0D%0A'
         15        ECHO                                                     ~9
   37    16        INIT_FCALL_BY_NAME                                       'PBKDF1'
         17        SEND_VAR_EX                                              !1
         18        SEND_VAR_EX                                              !2
         19        SEND_VAL_EX                                              1000
         20        SEND_VAL_EX                                              16
         21        DO_FCALL                                      0  $10     
         22        ASSIGN                                                   !4, $10
   39    23        INIT_FCALL                                               'base64_encode'
         24        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         25        FETCH_CONSTANT                                   ~12     'MCRYPT_RIJNDAEL_128'
         26        SEND_VAL_EX                                              ~12
         27        SEND_VAR_EX                                              !3
         28        SEND_VAR_EX                                              !0
         29        FETCH_CONSTANT                                   ~13     'MCRYPT_MODE_CBC'
         30        SEND_VAL_EX                                              ~13
         31        SEND_VAR_EX                                              !4
         32        DO_FCALL                                      0  $14     
         33        SEND_VAR                                                 $14
         34        DO_ICALL                                         $15     
         35      > RETURN                                                   $15
   40    36*     > RETURN                                                   null

End of function encrypt

Function pbkdf1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 13
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 13
Branch analysis from position: 21
Branch analysis from position: 13
filename:       /in/6rd3r
function name:  PBKDF1
number of ops:  29
compiled vars:  !0 = $pass, !1 = $salt, !2 = $count, !3 = $dklen, !4 = $t, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   44     4        CONCAT                                           ~6      !0, !1
          5        ASSIGN                                                   !4, ~6
   46     6        INIT_FCALL                                               'sha1'
          7        SEND_VAR                                                 !4
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !4, $8
   48    11        ASSIGN                                                   !5, 2
         12      > JMP                                                      ->19
   49    13    >   INIT_FCALL                                               'sha1'
         14        SEND_VAR                                                 !4
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $11     
         17        ASSIGN                                                   !4, $11
   48    18        PRE_INC                                                  !5
         19    >   IS_SMALLER_OR_EQUAL                                      !5, !2
         20      > JMPNZ                                                    ~14, ->13
   52    21    >   INIT_FCALL                                               'substr'
         22        SEND_VAR                                                 !4
         23        SEND_VAL                                                 0
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $15     
         26        ASSIGN                                                   !4, $15
   53    27      > RETURN                                                   !4
   54    28*     > RETURN                                                   null

End of function pbkdf1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.2 ms | 1477 KiB | 18 Q