3v4l.org

run code in 300+ PHP versions simultaneously
<?php function encrypt($string, $salt = NULL){ $mcrypt_iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $mcrypt_iv = mcrypt_create_iv($mcrypt_iv_size, MCRYPT_RAND); $mcrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hash('md5', $salt, true), $string, MCRYPT_MODE_ECB, $mcrypt_iv); $encoded = base64_encode($mcrypted); return $encoded; } function decrypt($hash, $salt = NULL){ $mcrypt_iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB); $mcrypt_iv = mcrypt_create_iv($mcrypt_iv_size, MCRYPT_RAND); $basedecoded = base64_decode($hash); $mcrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, hash('md5', $salt, true), $basedecoded, MCRYPT_MODE_ECB, $mcrypt_iv); return $mcrypted; } $en = encrypt('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ullamcorper turpis ut purus ultricies rhoncus. Suspendisse potenti. Donec nec tempor erat. Duis cursus tempus metus, ac elementum risus interdum nec. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer non dui vel ligula vestibulum tristique. Suspendisse vel purus erat. Cras sollicitudin arcu et leo mollis, ac elementum leo venenatis.', hash('sha512', 'test'))."\n";echo decrypt($en, hash('sha512', 'test'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXH3L
function name:  (null)
number of ops:  20
compiled vars:  !0 = $en
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'encrypt'
          1        SEND_VAL                                                 'Lorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit.+Suspendisse+ullamcorper+turpis+ut+purus+ultricies+rhoncus.+Suspendisse+potenti.+Donec+nec+tempor+erat.+Duis+cursus+tempus+metus%2C+ac+elementum+risus+interdum+nec.+Pellentesque+habitant+morbi+tristique+senectus+et+netus+et+malesuada+fames+ac+turpis+egestas.+Integer+non+dui+vel+ligula+vestibulum+tristique.+Suspendisse+vel+purus+erat.+Cras+sollicitudin+arcu+et+leo+mollis%2C+ac+elementum+leo+venenatis.'
          2        INIT_FCALL                                               'hash'
          3        SEND_VAL                                                 'sha512'
          4        SEND_VAL                                                 'test'
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        DO_FCALL                                      0  $2      
          8        CONCAT                                           ~3      $2, '%0A'
          9        ASSIGN                                                   !0, ~3
         10        INIT_FCALL                                               'decrypt'
         11        SEND_VAR                                                 !0
         12        INIT_FCALL                                               'hash'
         13        SEND_VAL                                                 'sha512'
         14        SEND_VAL                                                 'test'
         15        DO_ICALL                                         $5      
         16        SEND_VAR                                                 $5
         17        DO_FCALL                                      0  $6      
         18        ECHO                                                     $6
         19      > RETURN                                                   1

Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FXH3L
function name:  encrypt
number of ops:  36
compiled vars:  !0 = $string, !1 = $salt, !2 = $mcrypt_iv_size, !3 = $mcrypt_iv, !4 = $mcrypted, !5 = $encoded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    5     2        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          3        FETCH_CONSTANT                                   ~6      'MCRYPT_RIJNDAEL_128'
          4        SEND_VAL_EX                                              ~6
          5        FETCH_CONSTANT                                   ~7      'MCRYPT_MODE_ECB'
          6        SEND_VAL_EX                                              ~7
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !2, $8
    6     9        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         10        SEND_VAR_EX                                              !2
         11        FETCH_CONSTANT                                   ~10     'MCRYPT_RAND'
         12        SEND_VAL_EX                                              ~10
         13        DO_FCALL                                      0  $11     
         14        ASSIGN                                                   !3, $11
    8    15        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
         16        FETCH_CONSTANT                                   ~13     'MCRYPT_RIJNDAEL_128'
         17        SEND_VAL_EX                                              ~13
         18        INIT_FCALL                                               'hash'
         19        SEND_VAL                                                 'md5'
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 <true>
         22        DO_ICALL                                         $14     
         23        SEND_VAR_NO_REF_EX                                       $14
         24        SEND_VAR_EX                                              !0
         25        FETCH_CONSTANT                                   ~15     'MCRYPT_MODE_ECB'
         26        SEND_VAL_EX                                              ~15
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0  $16     
         29        ASSIGN                                                   !4, $16
   10    30        INIT_FCALL                                               'base64_encode'
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                         $18     
         33        ASSIGN                                                   !5, $18
   12    34      > RETURN                                                   !5
   13    35*     > 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/FXH3L
function name:  decrypt
number of ops:  36
compiled vars:  !0 = $hash, !1 = $salt, !2 = $mcrypt_iv_size, !3 = $mcrypt_iv, !4 = $basedecoded, !5 = $mcrypted
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   17     2        INIT_FCALL_BY_NAME                                       'mcrypt_get_iv_size'
          3        FETCH_CONSTANT                                   ~6      'MCRYPT_RIJNDAEL_128'
          4        SEND_VAL_EX                                              ~6
          5        FETCH_CONSTANT                                   ~7      'MCRYPT_MODE_ECB'
          6        SEND_VAL_EX                                              ~7
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !2, $8
   18     9        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         10        SEND_VAR_EX                                              !2
         11        FETCH_CONSTANT                                   ~10     'MCRYPT_RAND'
         12        SEND_VAL_EX                                              ~10
         13        DO_FCALL                                      0  $11     
         14        ASSIGN                                                   !3, $11
   20    15        INIT_FCALL                                               'base64_decode'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $13     
         18        ASSIGN                                                   !4, $13
   22    19        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
         20        FETCH_CONSTANT                                   ~15     'MCRYPT_RIJNDAEL_128'
         21        SEND_VAL_EX                                              ~15
         22        INIT_FCALL                                               'hash'
         23        SEND_VAL                                                 'md5'
         24        SEND_VAR                                                 !1
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $16     
         27        SEND_VAR_NO_REF_EX                                       $16
         28        SEND_VAR_EX                                              !4
         29        FETCH_CONSTANT                                   ~17     'MCRYPT_MODE_ECB'
         30        SEND_VAL_EX                                              ~17
         31        SEND_VAR_EX                                              !3
         32        DO_FCALL                                      0  $18     
         33        ASSIGN                                                   !5, $18
   24    34      > RETURN                                                   !5
   25    35*     > RETURN                                                   null

End of function decrypt

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.96 ms | 1407 KiB | 21 Q