3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Encryption { // The key const KEY = '36F3D40A7A41A827968BE75A87D6095036F3D40A7A41A827968BE75A87D60950'; /** * Encrypt a string * * @access public * @static * @param string $string * @return string */ public static function encrypt($string) { return mcrypt_encrypt(MCRYPT_RIJNDAEL_256, self::getMySQLKey(self::KEY), self::getPaddedString($string), MCRYPT_MODE_CBC, self::KEY); } /** * Decrypt a string * * @access public * @static * @param string $string * @return string */ public static function decrypt($string) { return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, self::getMySQLKey(self::KEY), $string, MCRYPT_MODE_CBC, self::KEY), "\x00..\x10"); } /** * Get MySQL key * * @access public * @static * @param string $key * @return string */ public static function getMySQLKey($key) { // The new key $new_key = str_repeat(chr(0), 32); // Iterate over the key and XOR for ($i = 0, $l = strlen($key); $i < $l; ++$i) { $new_key[$i % 32] = $new_key[$i % 32] ^ $key[$i]; } // Return the new key return $new_key; } /** * Get padded string * * @access public * @static * @param string $string * @return string */ public static function getPaddedString($string) { return str_pad($string, (16 * (floor(strlen($string) / 16) + 1)), chr(16 - (strlen($string) % 16))); } } echo base64_encode(Encryption::encrypt('michael@example.com'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nbniK
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   INIT_FCALL                                               'base64_encode'
          1        INIT_STATIC_METHOD_CALL                                  'Encryption', 'encrypt'
          2        SEND_VAL                                                 'michael%40example.com'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6        ECHO                                                     $1
          7      > RETURN                                                   1

Class Encryption:
Function encrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nbniK
function name:  encrypt
number of ops:  18
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
          2        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          3        SEND_VAL_EX                                              ~1
          4        INIT_STATIC_METHOD_CALL                                  'getMySQLKey'
          5        SEND_VAL_EX                                              '36F3D40A7A41A827968BE75A87D6095036F3D40A7A41A827968BE75A87D60950'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR_NO_REF_EX                                       $2
          8        INIT_STATIC_METHOD_CALL                                  'getPaddedString'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $3      
         11        SEND_VAR_NO_REF_EX                                       $3
         12        FETCH_CONSTANT                                   ~4      'MCRYPT_MODE_CBC'
         13        SEND_VAL_EX                                              ~4
         14        SEND_VAL_EX                                              '36F3D40A7A41A827968BE75A87D6095036F3D40A7A41A827968BE75A87D60950'
         15        DO_FCALL                                      0  $5      
         16      > RETURN                                                   $5
   19    17*     > 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/nbniK
function name:  decrypt
number of ops:  19
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'rtrim'
          2        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
          3        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          4        SEND_VAL_EX                                              ~1
          5        INIT_STATIC_METHOD_CALL                                  'getMySQLKey'
          6        SEND_VAL_EX                                              '36F3D40A7A41A827968BE75A87D6095036F3D40A7A41A827968BE75A87D60950'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR_NO_REF_EX                                       $2
          9        SEND_VAR_EX                                              !0
         10        FETCH_CONSTANT                                   ~3      'MCRYPT_MODE_CBC'
         11        SEND_VAL_EX                                              ~3
         12        SEND_VAL_EX                                              '36F3D40A7A41A827968BE75A87D6095036F3D40A7A41A827968BE75A87D60950'
         13        DO_FCALL                                      0  $4      
         14        SEND_VAR                                                 $4
         15        SEND_VAL                                                 '%00..%10'
         16        DO_ICALL                                         $5      
         17      > RETURN                                                   $5
   32    18*     > RETURN                                                   null

End of function decrypt

Function getmysqlkey:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 10
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 10
Branch analysis from position: 20
Branch analysis from position: 10
filename:       /in/nbniK
function name:  getMySQLKey
number of ops:  22
compiled vars:  !0 = $key, !1 = $new_key, !2 = $i, !3 = $l
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
   46     1        INIT_FCALL                                               'str_repeat'
          2        SEND_VAL                                                 '%00'
          3        SEND_VAL                                                 32
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   49     6        ASSIGN                                                   !2, 0
          7        STRLEN                                           ~7      !0
          8        ASSIGN                                                   !3, ~7
          9      > JMP                                                      ->18
   51    10    >   MOD                                              ~9      !2, 32
         11        MOD                                              ~11     !2, 32
         12        FETCH_DIM_R                                      ~12     !1, ~11
         13        FETCH_DIM_R                                      ~13     !0, !2
         14        BW_XOR                                           ~14     ~12, ~13
         15        ASSIGN_DIM                                               !1, ~9
         16        OP_DATA                                                  ~14
   49    17        PRE_INC                                                  !2
         18    >   IS_SMALLER                                               !2, !3
         19      > JMPNZ                                                    ~16, ->10
   55    20    > > RETURN                                                   !1
   57    21*     > RETURN                                                   null

End of function getmysqlkey

Function getpaddedstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nbniK
function name:  getPaddedString
number of ops:  21
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   RECV                                             !0      
   69     1        INIT_FCALL                                               'str_pad'
          2        SEND_VAR                                                 !0
          3        INIT_FCALL                                               'floor'
          4        STRLEN                                           ~1      !0
          5        DIV                                              ~2      ~1, 16
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8        ADD                                              ~4      $3, 1
          9        MUL                                              ~5      ~4, 16
         10        SEND_VAL                                                 ~5
         11        INIT_FCALL                                               'chr'
         12        STRLEN                                           ~6      !0
         13        MOD                                              ~7      ~6, 16
         14        SUB                                              ~8      16, ~7
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                         $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                         $10     
         19      > RETURN                                                   $10
   70    20*     > RETURN                                                   null

End of function getpaddedstring

End of class Encryption.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.37 ms | 1404 KiB | 25 Q