3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Emulate OpenFire Blowfish Class */ class OpenFireBlowfish { private $key; private $cipher; public $enckey = "70S28ao84z4wGS7"; //Hidden Encryption Key of Openfire BlowFish public $enciv = ''; function __construct($pass) { $this->cipher = mcrypt_module_open('blowfish','','cbc',''); $ks = mcrypt_enc_get_key_size($this->cipher); $this->key = pack('H*',sha1($pass)); } function encryptString($plaintext, $iv = '') { if ($iv == '') { $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($this->cipher)); } else { $iv = pack("H*", $iv); } mcrypt_generic_init($this->cipher, $this->key, $iv); $bs = mcrypt_enc_get_block_size($this->cipher); // get block size $plaintext = mb_convert_encoding($plaintext,'UTF-16BE'); // set to 2 byte, network order $pkcs = $bs - (strlen($plaintext) % $bs); // get pkcs5 pad length $pkcs = str_repeat(chr($pkcs), $pkcs); // create padding string $plaintext = $plaintext.$pkcs; // append pkcs5 padding to the data $result = mcrypt_generic($this->cipher, $plaintext); mcrypt_generic_deinit($this->cipher); return $iv.$result; } function decryptString($ciphertext) { $bs = mcrypt_enc_get_block_size($this->cipher); // get block size $iv_size = mcrypt_enc_get_iv_size($this->cipher); if ((strlen($ciphertext) % $bs) != 0) { // check string is proper size exit(1); } $iv = substr($ciphertext, 0, $iv_size); // retrieve IV $ciphertext = substr($ciphertext, $iv_size); mcrypt_generic_init($this->cipher, $this->key, $iv); $result = mdecrypt_generic($this->cipher, $ciphertext); // decrypt //echo var_dump(unpack('c*',$iv))."\n"; $padding = ord(substr($result,-1)); // retrieve padding $result = substr($result,0,$padding * -1); // and remove it mcrypt_generic_deinit($this->cipher); return $result; } function __destruct() { mcrypt_module_close($this->cipher); } } // Test OpenFire Blowfish Class $enckey = "70S28ao84z4wGS7"; //paste your openfire Db passwordKey copied in poin# 3 $enciv = ''; $a = new OpenFireBlowfish($enckey); $encstring = bin2hex($a->encryptString('password',$enciv)); //enter your password string to encrypt it echo "Encrypted Password string:".$encstring . "<br>"; echo "Original Password string:".$a->decryptString(pack("H*", "f84cbd64e079a04c0c9368937702d70251a06e7e86852429cfda6235e391febe")) . "<br>"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUWCJ
function name:  (null)
number of ops:  28
compiled vars:  !0 = $enckey, !1 = $enciv, !2 = $a, !3 = $encstring
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   ASSIGN                                                   !0, '70S28ao84z4wGS7'
   72     1        ASSIGN                                                   !1, ''
   75     2        NEW                                              $6      'OpenFireBlowfish'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   78     6        INIT_FCALL                                               'bin2hex'
          7        INIT_METHOD_CALL                                         !2, 'encryptString'
          8        SEND_VAL_EX                                              'password'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $9      
         11        SEND_VAR                                                 $9
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !3, $10
   79    14        CONCAT                                           ~12     'Encrypted+Password+string%3A', !3
         15        CONCAT                                           ~13     ~12, '%3Cbr%3E'
         16        ECHO                                                     ~13
   82    17        INIT_METHOD_CALL                                         !2, 'decryptString'
         18        INIT_FCALL                                               'pack'
         19        SEND_VAL                                                 'H%2A'
         20        SEND_VAL                                                 'f84cbd64e079a04c0c9368937702d70251a06e7e86852429cfda6235e391febe'
         21        DO_ICALL                                         $14     
         22        SEND_VAR_NO_REF_EX                                       $14
         23        DO_FCALL                                      0  $15     
         24        CONCAT                                           ~16     'Original+Password+string%3A', $15
         25        CONCAT                                           ~17     ~16, '%3Cbr%3E'
         26        ECHO                                                     ~17
   85    27      > RETURN                                                   1

Class OpenFireBlowfish:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUWCJ
function name:  __construct
number of ops:  25
compiled vars:  !0 = $pass, !1 = $ks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL_BY_NAME                                       'mcrypt_module_open'
          2        SEND_VAL_EX                                              'blowfish'
          3        SEND_VAL_EX                                              ''
          4        SEND_VAL_EX                                              'cbc'
          5        SEND_VAL_EX                                              ''
          6        DO_FCALL                                      0  $3      
          7        ASSIGN_OBJ                                               'cipher'
          8        OP_DATA                                                  $3
   19     9        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_key_size'
         10        CHECK_FUNC_ARG                                           
         11        FETCH_OBJ_FUNC_ARG                               $4      'cipher'
         12        SEND_FUNC_ARG                                            $4
         13        DO_FCALL                                      0  $5      
         14        ASSIGN                                                   !1, $5
   20    15        INIT_FCALL                                               'pack'
         16        SEND_VAL                                                 'H%2A'
         17        INIT_FCALL                                               'sha1'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $8      
         20        SEND_VAR                                                 $8
         21        DO_ICALL                                         $9      
         22        ASSIGN_OBJ                                               'key'
         23        OP_DATA                                                  $9
   21    24      > RETURN                                                   null

End of function __construct

Function encryptstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUWCJ
function name:  encryptString
number of ops:  68
compiled vars:  !0 = $plaintext, !1 = $iv, !2 = $bs, !3 = $pkcs, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
   26     2        IS_EQUAL                                                 !1, ''
          3      > JMPZ                                                     ~5, ->14
   27     4    >   INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
          5        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_iv_size'
          6        CHECK_FUNC_ARG                                           
          7        FETCH_OBJ_FUNC_ARG                               $6      'cipher'
          8        SEND_FUNC_ARG                                            $6
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR_NO_REF_EX                                       $7
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !1, $8
         13      > JMP                                                      ->19
   30    14    >   INIT_FCALL                                               'pack'
         15        SEND_VAL                                                 'H%2A'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !1, $10
   32    19    >   INIT_FCALL_BY_NAME                                       'mcrypt_generic_init'
         20        CHECK_FUNC_ARG                                           
         21        FETCH_OBJ_FUNC_ARG                               $12     'cipher'
         22        SEND_FUNC_ARG                                            $12
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $13     'key'
         25        SEND_FUNC_ARG                                            $13
         26        SEND_VAR_EX                                              !1
         27        DO_FCALL                                      0          
   33    28        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_block_size'
         29        CHECK_FUNC_ARG                                           
         30        FETCH_OBJ_FUNC_ARG                               $15     'cipher'
         31        SEND_FUNC_ARG                                            $15
         32        DO_FCALL                                      0  $16     
         33        ASSIGN                                                   !2, $16
   34    34        INIT_FCALL                                               'mb_convert_encoding'
         35        SEND_VAR                                                 !0
         36        SEND_VAL                                                 'UTF-16BE'
         37        DO_ICALL                                         $18     
         38        ASSIGN                                                   !0, $18
   35    39        STRLEN                                           ~20     !0
         40        MOD                                              ~21     ~20, !2
         41        SUB                                              ~22     !2, ~21
         42        ASSIGN                                                   !3, ~22
   36    43        INIT_FCALL                                               'str_repeat'
         44        INIT_FCALL                                               'chr'
         45        SEND_VAR                                                 !3
         46        DO_ICALL                                         $24     
         47        SEND_VAR                                                 $24
         48        SEND_VAR                                                 !3
         49        DO_ICALL                                         $25     
         50        ASSIGN                                                   !3, $25
   37    51        CONCAT                                           ~27     !0, !3
         52        ASSIGN                                                   !0, ~27
   38    53        INIT_FCALL_BY_NAME                                       'mcrypt_generic'
         54        CHECK_FUNC_ARG                                           
         55        FETCH_OBJ_FUNC_ARG                               $29     'cipher'
         56        SEND_FUNC_ARG                                            $29
         57        SEND_VAR_EX                                              !0
         58        DO_FCALL                                      0  $30     
         59        ASSIGN                                                   !4, $30
   39    60        INIT_FCALL_BY_NAME                                       'mcrypt_generic_deinit'
         61        CHECK_FUNC_ARG                                           
         62        FETCH_OBJ_FUNC_ARG                               $32     'cipher'
         63        SEND_FUNC_ARG                                            $32
         64        DO_FCALL                                      0          
   40    65        CONCAT                                           ~34     !1, !4
         66      > RETURN                                                   ~34
   41    67*     > RETURN                                                   null

End of function encryptstring

Function decryptstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUWCJ
function name:  decryptString
number of ops:  67
compiled vars:  !0 = $ciphertext, !1 = $bs, !2 = $iv_size, !3 = $iv, !4 = $result, !5 = $padding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_block_size'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $6      'cipher'
          4        SEND_FUNC_ARG                                            $6
          5        DO_FCALL                                      0  $7      
          6        ASSIGN                                                   !1, $7
   47     7        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_iv_size'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $9      'cipher'
         10        SEND_FUNC_ARG                                            $9
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                                   !2, $10
   48    13        STRLEN                                           ~12     !0
         14        MOD                                              ~13     ~12, !1
         15        IS_NOT_EQUAL                                             ~13, 0
         16      > JMPZ                                                     ~14, ->18
   49    17    > > EXIT                                                     1
   51    18    >   INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        SEND_VAL                                                 0
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        ASSIGN                                                   !3, $15
   52    24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $17     
         28        ASSIGN                                                   !0, $17
   53    29        INIT_FCALL_BY_NAME                                       'mcrypt_generic_init'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_OBJ_FUNC_ARG                               $19     'cipher'
         32        SEND_FUNC_ARG                                            $19
         33        CHECK_FUNC_ARG                                           
         34        FETCH_OBJ_FUNC_ARG                               $20     'key'
         35        SEND_FUNC_ARG                                            $20
         36        SEND_VAR_EX                                              !3
         37        DO_FCALL                                      0          
   54    38        INIT_FCALL_BY_NAME                                       'mdecrypt_generic'
         39        CHECK_FUNC_ARG                                           
         40        FETCH_OBJ_FUNC_ARG                               $22     'cipher'
         41        SEND_FUNC_ARG                                            $22
         42        SEND_VAR_EX                                              !0
         43        DO_FCALL                                      0  $23     
         44        ASSIGN                                                   !4, $23
   56    45        INIT_FCALL                                               'ord'
         46        INIT_FCALL                                               'substr'
         47        SEND_VAR                                                 !4
         48        SEND_VAL                                                 -1
         49        DO_ICALL                                         $25     
         50        SEND_VAR                                                 $25
         51        DO_ICALL                                         $26     
         52        ASSIGN                                                   !5, $26
   57    53        INIT_FCALL                                               'substr'
         54        SEND_VAR                                                 !4
         55        SEND_VAL                                                 0
         56        MUL                                              ~28     !5, -1
         57        SEND_VAL                                                 ~28
         58        DO_ICALL                                         $29     
         59        ASSIGN                                                   !4, $29
   58    60        INIT_FCALL_BY_NAME                                       'mcrypt_generic_deinit'
         61        CHECK_FUNC_ARG                                           
         62        FETCH_OBJ_FUNC_ARG                               $31     'cipher'
         63        SEND_FUNC_ARG                                            $31
         64        DO_FCALL                                      0          
   59    65      > RETURN                                                   !4
   60    66*     > RETURN                                                   null

End of function decryptstring

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SUWCJ
function name:  __destruct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   INIT_FCALL_BY_NAME                                       'mcrypt_module_close'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'cipher'
          3        SEND_FUNC_ARG                                            $0
          4        DO_FCALL                                      0          
   66     5      > RETURN                                                   null

End of function __destruct

End of class OpenFireBlowfish.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.76 ms | 1412 KiB | 29 Q