3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CryptToken { private static $instance; private $crypt; private $token; private $context; public function __construct() { $this->InitCrypt(); } private function InitCrypt() { $this->crypt = (object)array(); $this->crypt->key = hash('sha512', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); } public static function GetInstance() { if(!isset(self::$instance)) { self::$instance = new self(); } return self::$instance; } public function Decrypt($buffer) { return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, pack('H*', substr($this->crypt->key, 0, 64)), base64_decode($buffer), MCRYPT_MODE_OFB, pack('H*', substr($this->crypt->key, -64))); } public function Crypt($buffer) { return base64_encode( mcrypt_encrypt(MCRYPT_RIJNDAEL_256, pack('H*', substr($this->crypt->key, 0, 64)), $buffer, MCRYPT_MODE_OFB, pack('H*', substr($this->crypt->key, -64)))); } public function ParseToken($token) { $this->token = explode('|', $token); $this->ExtractValue(); return $this; } private function ExtractValue() { foreach($this->token as $item) { $current = explode('=', $item); if(count($current) == 2) { $this->context->{$current[0]} = $current[1]; } } } public function TimeStampCheck() { if($this->context->ts >= time()) { return true; } return false; } public function AdminCheck() { if($this->context->user == 'admin') { return true; } return false; } } echo time(); echo "\n"; echo CryptToken::GetInstance()->Crypt('user=admin|ts=' . (time() + 1000));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   INIT_FCALL                                               'time'
          1        DO_ICALL                                         $0      
          2        ECHO                                                     $0
   75     3        ECHO                                                     '%0A'
   76     4        INIT_STATIC_METHOD_CALL                                  'CryptToken', 'GetInstance'
          5        DO_FCALL                                      0  $1      
          6        INIT_METHOD_CALL                                         $1, 'Crypt'
          7        INIT_FCALL                                               'time'
          8        DO_ICALL                                         $2      
          9        ADD                                              ~3      $2, 1000
         10        CONCAT                                           ~4      'user%3Dadmin%7Cts%3D', ~3
         11        SEND_VAL_EX                                              ~4
         12        DO_FCALL                                      0  $5      
         13        ECHO                                                     $5
         14      > RETURN                                                   1

Class CryptToken:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_METHOD_CALL                                         'InitCrypt'
          1        DO_FCALL                                      0          
   11     2      > RETURN                                                   null

End of function __construct

Function initcrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  InitCrypt
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   CAST                                          8  ~1      <array>
          1        ASSIGN_OBJ                                               'crypt'
          2        OP_DATA                                                  ~1
   15     3        INIT_FCALL                                               'hash'
          4        SEND_VAL                                                 'sha512'
          5        SEND_VAL                                                 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
          6        DO_ICALL                                         $4      
          7        FETCH_OBJ_W                                      $2      'crypt'
          8        ASSIGN_OBJ                                               $2, 'key'
          9        OP_DATA                                                  $4
   16    10      > RETURN                                                   null

End of function initcrypt

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/OAF8H
function name:  GetInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ISSET_ISEMPTY_STATIC_PROP                        ~0      'instance'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
   20     3    >   NEW                          self                $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   22     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   23     9*     > RETURN                                                   null

End of function getinstance

Function decrypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  Decrypt
number of ops:  36
compiled vars:  !0 = $buffer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   27     1        INIT_FCALL_BY_NAME                                       'mcrypt_decrypt'
          2        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          3        SEND_VAL_EX                                              ~1
   28     4        INIT_FCALL                                               'pack'
          5        SEND_VAL                                                 'H%2A'
          6        INIT_FCALL                                               'substr'
          7        FETCH_OBJ_R                                      ~2      'crypt'
          8        FETCH_OBJ_R                                      ~3      ~2, 'key'
          9        SEND_VAL                                                 ~3
         10        SEND_VAL                                                 0
         11        SEND_VAL                                                 64
         12        DO_ICALL                                         $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                         $5      
         15        SEND_VAR_NO_REF_EX                                       $5
   29    16        INIT_FCALL                                               'base64_decode'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $6      
         19        SEND_VAR_NO_REF_EX                                       $6
   30    20        FETCH_CONSTANT                                   ~7      'MCRYPT_MODE_OFB'
         21        SEND_VAL_EX                                              ~7
   31    22        INIT_FCALL                                               'pack'
         23        SEND_VAL                                                 'H%2A'
         24        INIT_FCALL                                               'substr'
         25        FETCH_OBJ_R                                      ~8      'crypt'
         26        FETCH_OBJ_R                                      ~9      ~8, 'key'
         27        SEND_VAL                                                 ~9
         28        SEND_VAL                                                 -64
         29        DO_ICALL                                         $10     
         30        SEND_VAR                                                 $10
         31        DO_ICALL                                         $11     
         32        SEND_VAR_NO_REF_EX                                       $11
         33        DO_FCALL                                      0  $12     
         34      > RETURN                                                   $12
   32    35*     > RETURN                                                   null

End of function decrypt

Function crypt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  Crypt
number of ops:  36
compiled vars:  !0 = $buffer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'base64_encode'
   37     2        INIT_FCALL_BY_NAME                                       'mcrypt_encrypt'
          3        FETCH_CONSTANT                                   ~1      'MCRYPT_RIJNDAEL_256'
          4        SEND_VAL_EX                                              ~1
   38     5        INIT_FCALL                                               'pack'
          6        SEND_VAL                                                 'H%2A'
          7        INIT_FCALL                                               'substr'
          8        FETCH_OBJ_R                                      ~2      'crypt'
          9        FETCH_OBJ_R                                      ~3      ~2, 'key'
         10        SEND_VAL                                                 ~3
         11        SEND_VAL                                                 0
         12        SEND_VAL                                                 64
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                         $5      
         16        SEND_VAR_NO_REF_EX                                       $5
   37    17        SEND_VAR_EX                                              !0
   40    18        FETCH_CONSTANT                                   ~6      'MCRYPT_MODE_OFB'
         19        SEND_VAL_EX                                              ~6
   41    20        INIT_FCALL                                               'pack'
         21        SEND_VAL                                                 'H%2A'
         22        INIT_FCALL                                               'substr'
         23        FETCH_OBJ_R                                      ~7      'crypt'
         24        FETCH_OBJ_R                                      ~8      ~7, 'key'
         25        SEND_VAL                                                 ~8
         26        SEND_VAL                                                 -64
         27        DO_ICALL                                         $9      
         28        SEND_VAR                                                 $9
         29        DO_ICALL                                         $10     
         30        SEND_VAR_NO_REF_EX                                       $10
         31        DO_FCALL                                      0  $11     
         32        SEND_VAR                                                 $11
         33        DO_ICALL                                         $12     
         34      > RETURN                                                   $12
   42    35*     > RETURN                                                   null

End of function crypt

Function parsetoken:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  ParseToken
number of ops:  12
compiled vars:  !0 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   45     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN_OBJ                                               'token'
          6        OP_DATA                                                  $2
   46     7        INIT_METHOD_CALL                                         'ExtractValue'
          8        DO_FCALL                                      0          
   47     9        FETCH_THIS                                       ~4      
         10      > RETURN                                                   ~4
   48    11*     > RETURN                                                   null

End of function parsetoken

Function extractvalue:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 17
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/OAF8H
function name:  ExtractValue
number of ops:  19
compiled vars:  !0 = $item, !1 = $current
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   FETCH_OBJ_R                                      ~2      'token'
          1      > FE_RESET_R                                       $3      ~2, ->17
          2    > > FE_FETCH_R                                               $3, !0, ->17
   52     3    >   INIT_FCALL                                               'explode'
          4        SEND_VAL                                                 '%3D'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !1, $4
   53     8        COUNT                                            ~6      !1
          9        IS_EQUAL                                                 ~6, 2
         10      > JMPZ                                                     ~7, ->16
   54    11    >   FETCH_DIM_R                                      ~9      !1, 0
         12        FETCH_DIM_R                                      ~11     !1, 1
         13        FETCH_OBJ_W                                      $8      'context'
         14        ASSIGN_OBJ                                               $8, ~9
         15        OP_DATA                                                  ~11
   51    16    > > JMP                                                      ->2
         17    >   FE_FREE                                                  $3
   57    18      > RETURN                                                   null

End of function extractvalue

Function timestampcheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  TimeStampCheck
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   FETCH_OBJ_R                                      ~0      'context'
          1        FETCH_OBJ_R                                      ~1      ~0, 'ts'
          2        INIT_FCALL                                               'time'
          3        DO_ICALL                                         $2      
          4        IS_SMALLER_OR_EQUAL                                      $2, ~1
          5      > JMPZ                                                     ~3, ->7
   61     6    > > RETURN                                                   <true>
   63     7    > > RETURN                                                   <false>
   64     8*     > RETURN                                                   null

End of function timestampcheck

Function admincheck:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/OAF8H
function name:  AdminCheck
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   FETCH_OBJ_R                                      ~0      'context'
          1        FETCH_OBJ_R                                      ~1      ~0, 'user'
          2        IS_EQUAL                                                 ~1, 'admin'
          3      > JMPZ                                                     ~2, ->5
   68     4    > > RETURN                                                   <true>
   70     5    > > RETURN                                                   <false>
   71     6*     > RETURN                                                   null

End of function admincheck

End of class CryptToken.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.62 ms | 1404 KiB | 27 Q