3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This class helps building secure password-hashes (BCrypt) with PHP, * to store them in the database. It is provided with comments, for * educational purposes. * * @author Martin Stoeckli - www.martinstoeckli.ch/php * @copyright Martin Stoeckli 2013, this code may be freely used in every * type of project, it is provided without warranties of any kind. */ class StoPasswordHash { /** * Generates a bcrypt hash of a password, which can be stored in a database. * @param string $password Password whose hash-value we need. * @param int $cost Controls the number of iterations. Increasing the cost * by 1, doubles the needed calculation time. Must be in the range of 4-31. * @param string $serverSideKey This key acts similar to a pepper, but * can be exchanged when necessary. In certain situations, encrypting * the hash-value can protect weak passwords from a dictionary attack. * @return string Hash-value of the password. A random salt is included. * Without passing a $serverSideKey the result has a length of 60 * characters, with a $serverSideKey the length is 108 characters. */ public static function hashBcrypt($password, $cost=10, $serverSideKey='') { if (!defined('CRYPT_BLOWFISH')) throw new Exception('The CRYPT_BLOWFISH algorithm is required (PHP 5.3).'); if ($cost < 4 || $cost > 31) throw new InvalidArgumentException('The cost factor must be a number between 4 and 31'); if (version_compare(PHP_VERSION, '5.3.7') >= 0) $algorithm = '2y'; // BCrypt, with fixed unicode problem else $algorithm = '2a'; // BCrypt // BCrypt expects nearly the same alphabet as base64_encode returns, // but instead of the '+' characters it accepts '.' characters. // BCrypt alphabet: ./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz $salt = str_replace('+', '.', StoPasswordHash::generateRandomBase64String(22)); // Create crypt parameters: $algorithm$cost$salt $cryptParams = sprintf('$%s$%02d$%s', $algorithm, $cost, $salt); $hash = crypt($password, $cryptParams); // Encrypt hash with the server side key if ($serverSideKey != '') { $encryptedHash = StoPasswordHash::encryptTwofish($hash, $serverSideKey); $hash = base64_encode($encryptedHash); } return $hash; } /** * Checks, if the password matches a given hash value. This is useful when * a user enters his password for login, to check if the password corresponds * to the hash stored in the database. * @param string $password Password to check. * @param string $existingHash Stored hash-value from the database. * @param string $serverSideKey Pass the same key that was used to encrypt * $existingHash, or omit this parameter if no key was used. * @return bool Returns true, if the password matches the hash, * otherwise false. */ public static function verify($password, $existingHash, $serverSideKey='') { if (!defined('CRYPT_BLOWFISH')) throw new Exception('The CRYPT_BLOWFISH algorithm is required (PHP 5.3).'); // Decrypt hash with the server side key if ($serverSideKey != '') { $encryptedHash = base64_decode($existingHash); $existingHash = StoPasswordHash::decryptTwofish($encryptedHash, $serverSideKey); } // The parameters that where used to generate $existingHash, will be // extracted automatically from the first 29 characters of $existingHash. $newHash = crypt($password, $existingHash); return $newHash === $existingHash; } /** * Allows to change the server-side key, or to add/remove the encryption. * @param string $existingHash Encrypted or unencrypted hash-value. * @param string $oldKey Pass the key, that was used to encrypt * $existingHash, or pass '' if the hash is not yet encrypted. * @param string $newKey Pass a new key, to encrypt $existingHash, or * pass '' to remove the encryption. * @return string New encrypted/decrypted hash-value. */ public static function changeServerSideKey($existingHash, $oldKey, $newKey) { // decrypt hash-value $hash = $existingHash; if ($oldKey != '') { $encryptedHash = base64_decode($hash); $hash = StoPasswordHash::decryptTwofish($encryptedHash, $oldKey); } // encrypt hash-value if ($newKey != '') { $encryptedHash = StoPasswordHash::encryptTwofish($hash, $newKey); $hash = base64_encode($encryptedHash); } return $hash; } /** * Generates a random string of a given length, using the random source of * the operating system. The string contains only characters of this * alphabet: +/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz * @param int $length Number of characters the string should have. * @return string A random base64 encoded string. */ protected static function generateRandomBase64String($length) { if (!defined('MCRYPT_DEV_URANDOM')) throw new Exception('The MCRYPT_DEV_URANDOM source is required (PHP 5.3).'); // Generate random bytes, using the operating system's random source. // Since PHP 5.3 this also uses the random source on a Windows server. // Unlike /dev/random, the /dev/urandom does not block the server, if // there is not enough entropy available. $binaryLength = (int)($length * 3 / 4 + 1); $randomBinaryString = mcrypt_create_iv($binaryLength, MCRYPT_DEV_URANDOM); $randomBase64String = base64_encode($randomBinaryString); return substr($randomBase64String, 0, $length); } /** * Encrypts data with the TWOFISH algorithm. The IV vector will be * included in the resulting binary string. * @param string $data Data to encrypt. Trailing \0 characters will get lost. * @param string $key This key will be used to encrypt the data. The key * will be hashed to a binary representation before it is used. * @return string Returns the encrypted data in form of a binary string. */ public static function encryptTwofish($data, $key) { if (!defined('MCRYPT_DEV_URANDOM')) throw new Exception('The MCRYPT_DEV_URANDOM source is required (PHP 5.3).'); if (!defined('MCRYPT_TWOFISH')) throw new Exception('The MCRYPT_TWOFISH algorithm is required (PHP 5.3).'); // The cbc mode is preferable over the ecb mode $td = mcrypt_module_open(MCRYPT_TWOFISH, '', MCRYPT_MODE_CBC, ''); // Twofish accepts a key of 32 bytes. Because usually longer strings // with only readable characters are passed, we build a binary string. $binaryKey = hash('sha256', $key, true); // Create initialization vector of 16 bytes $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_DEV_URANDOM); mcrypt_generic_init($td, $binaryKey, $iv); $encryptedData = mcrypt_generic($td, $data); mcrypt_generic_deinit($td); mcrypt_module_close($td); // Combine iv and encrypted text return $iv . $encryptedData; } /** * Decrypts data, formerly encrypted with @see encryptTwofish. * @param string $encryptedData Binary string with encrypted data. * @param string $key This key will be used to decrypt the data. * @return string Returns the original decrypted data. */ public static function decryptTwofish($encryptedData, $key) { if (!defined('MCRYPT_TWOFISH')) throw new Exception('The MCRYPT_TWOFISH algorithm is required (PHP 5.3).'); $td = mcrypt_module_open(MCRYPT_TWOFISH, '', MCRYPT_MODE_CBC, ''); // Extract initialization vector from encrypted data $ivSize = mcrypt_enc_get_iv_size($td); $iv = substr($encryptedData, 0, $ivSize); $encryptedData = substr($encryptedData, $ivSize); $binaryKey = hash('sha256', $key, true); mcrypt_generic_init($td, $binaryKey, $iv); $decryptedData = mdecrypt_generic($td, $encryptedData); mcrypt_generic_deinit($td); mcrypt_module_close($td); // Original data was padded with 0-characters to block-size return rtrim($decryptedData, "\0"); } protected static function calculateTwofishLength($inputLength) { $td = mcrypt_module_open(MCRYPT_TWOFISH, '', MCRYPT_MODE_CBC, ''); $ivSize = mcrypt_enc_get_iv_size($td); $blockSize = mcrypt_enc_get_block_size($td); mcrypt_module_close($td); return $ivSize + ceil($inputLength / $blockSize) * $blockSize; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7fkQ0
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  201     0  E > > RETURN                                                   1

Class StoPasswordHash:
Function hashbcrypt:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 47) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 58
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 58
Branch analysis from position: 49
Branch analysis from position: 58
Branch analysis from position: 12
filename:       /in/7fkQ0
function name:  hashBcrypt
number of ops:  60
compiled vars:  !0 = $password, !1 = $cost, !2 = $serverSideKey, !3 = $algorithm, !4 = $salt, !5 = $cryptParams, !6 = $hash, !7 = $encryptedHash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      10
          2        RECV_INIT                                        !2      ''
   28     3      > JMPZ                                                     <false>, ->8
          4    >   NEW                                              $8      'Exception'
          5        SEND_VAL_EX                                              'The+CRYPT_BLOWFISH+algorithm+is+required+%28PHP+5.3%29.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $8
   29     8    >   IS_SMALLER                                       ~10     !1, 4
          9      > JMPNZ_EX                                         ~10     ~10, ->12
         10    >   IS_SMALLER                                       ~11     31, !1
         11        BOOL                                             ~10     ~11
         12    > > JMPZ                                                     ~10, ->17
         13    >   NEW                                              $12     'InvalidArgumentException'
         14        SEND_VAL_EX                                              'The+cost+factor+must+be+a+number+between+4+and+31'
         15        DO_FCALL                                      0          
         16      > THROW                                         0          $12
   31    17    >   INIT_FCALL                                               'version_compare'
         18        SEND_VAL                                                 '8.0.0'
         19        SEND_VAL                                                 '5.3.7'
         20        DO_ICALL                                         $14     
         21        IS_SMALLER_OR_EQUAL                                      0, $14
         22      > JMPZ                                                     ~15, ->25
   32    23    >   ASSIGN                                                   !3, '2y'
         24      > JMP                                                      ->26
   34    25    >   ASSIGN                                                   !3, '2a'
   39    26    >   INIT_FCALL                                               'str_replace'
         27        SEND_VAL                                                 '%2B'
         28        SEND_VAL                                                 '.'
         29        INIT_STATIC_METHOD_CALL                                  'StoPasswordHash', 'generateRandomBase64String'
         30        SEND_VAL_EX                                              22
         31        DO_FCALL                                      0  $18     
         32        SEND_VAR                                                 $18
         33        DO_ICALL                                         $19     
         34        ASSIGN                                                   !4, $19
   42    35        INIT_FCALL                                               'sprintf'
         36        SEND_VAL                                                 '%24%25s%24%2502d%24%25s'
         37        SEND_VAR                                                 !3
         38        SEND_VAR                                                 !1
         39        SEND_VAR                                                 !4
         40        DO_ICALL                                         $21     
         41        ASSIGN                                                   !5, $21
   43    42        INIT_FCALL                                               'crypt'
         43        SEND_VAR                                                 !0
         44        SEND_VAR                                                 !5
         45        DO_ICALL                                         $23     
         46        ASSIGN                                                   !6, $23
   46    47        IS_NOT_EQUAL                                             !2, ''
         48      > JMPZ                                                     ~25, ->58
   48    49    >   INIT_STATIC_METHOD_CALL                                  'StoPasswordHash', 'encryptTwofish'
         50        SEND_VAR_EX                                              !6
         51        SEND_VAR_EX                                              !2
         52        DO_FCALL                                      0  $26     
         53        ASSIGN                                                   !7, $26
   49    54        INIT_FCALL                                               'base64_encode'
         55        SEND_VAR                                                 !7
         56        DO_ICALL                                         $28     
         57        ASSIGN                                                   !6, $28
   51    58    > > RETURN                                                   !6
   52    59*     > RETURN                                                   null

End of function hashbcrypt

Function verify:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/7fkQ0
function name:  verify
number of ops:  27
compiled vars:  !0 = $password, !1 = $existingHash, !2 = $serverSideKey, !3 = $encryptedHash, !4 = $newHash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      ''
   67     3      > JMPZ                                                     <false>, ->8
          4    >   NEW                                              $5      'Exception'
          5        SEND_VAL_EX                                              'The+CRYPT_BLOWFISH+algorithm+is+required+%28PHP+5.3%29.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $5
   70     8    >   IS_NOT_EQUAL                                             !2, ''
          9      > JMPZ                                                     ~7, ->19
   72    10    >   INIT_FCALL                                               'base64_decode'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !3, $8
   73    14        INIT_STATIC_METHOD_CALL                                  'StoPasswordHash', 'decryptTwofish'
         15        SEND_VAR_EX                                              !3
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $10     
         18        ASSIGN                                                   !1, $10
   78    19    >   INIT_FCALL                                               'crypt'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $12     
         23        ASSIGN                                                   !4, $12
   79    24        IS_IDENTICAL                                     ~14     !4, !1
         25      > RETURN                                                   ~14
   80    26*     > RETURN                                                   null

End of function verify

Function changeserversidekey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 15
filename:       /in/7fkQ0
function name:  changeServerSideKey
number of ops:  28
compiled vars:  !0 = $existingHash, !1 = $oldKey, !2 = $newKey, !3 = $hash, !4 = $encryptedHash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   91     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   94     3        ASSIGN                                                   !3, !0
   95     4        IS_NOT_EQUAL                                             !1, ''
          5      > JMPZ                                                     ~6, ->15
   97     6    >   INIT_FCALL                                               'base64_decode'
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !4, $7
   98    10        INIT_STATIC_METHOD_CALL                                  'StoPasswordHash', 'decryptTwofish'
         11        SEND_VAR_EX                                              !4
         12        SEND_VAR_EX                                              !1
         13        DO_FCALL                                      0  $9      
         14        ASSIGN                                                   !3, $9
  102    15    >   IS_NOT_EQUAL                                             !2, ''
         16      > JMPZ                                                     ~11, ->26
  104    17    >   INIT_STATIC_METHOD_CALL                                  'StoPasswordHash', 'encryptTwofish'
         18        SEND_VAR_EX                                              !3
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0  $12     
         21        ASSIGN                                                   !4, $12
  105    22        INIT_FCALL                                               'base64_encode'
         23        SEND_VAR                                                 !4
         24        DO_ICALL                                         $14     
         25        ASSIGN                                                   !3, $14
  107    26    > > RETURN                                                   !3
  108    27*     > RETURN                                                   null

End of function changeserversidekey

Function generaterandombase64string:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7fkQ0
function name:  generateRandomBase64String
number of ops:  30
compiled vars:  !0 = $length, !1 = $binaryLength, !2 = $randomBinaryString, !3 = $randomBase64String
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  117     0  E >   RECV                                             !0      
  119     1        DEFINED                                          ~4      'MCRYPT_DEV_URANDOM'
          2        BOOL_NOT                                         ~5      ~4
          3      > JMPZ                                                     ~5, ->8
          4    >   NEW                                              $6      'Exception'
          5        SEND_VAL_EX                                              'The+MCRYPT_DEV_URANDOM+source+is+required+%28PHP+5.3%29.'
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $6
  125     8    >   MUL                                              ~8      !0, 3
          9        DIV                                              ~9      ~8, 4
         10        ADD                                              ~10     ~9, 1
         11        CAST                                          4  ~11     ~10
         12        ASSIGN                                                   !1, ~11
  126    13        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         14        SEND_VAR_EX                                              !1
         15        FETCH_CONSTANT                                   ~13     'MCRYPT_DEV_URANDOM'
         16        SEND_VAL_EX                                              ~13
         17        DO_FCALL                                      0  $14     
         18        ASSIGN                                                   !2, $14
  127    19        INIT_FCALL                                               'base64_encode'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !3, $16
  128    23        INIT_FCALL                                               'substr'
         24        SEND_VAR                                                 !3
         25        SEND_VAL                                                 0
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                         $18     
         28      > RETURN                                                   $18
  129    29*     > RETURN                                                   null

End of function generaterandombase64string

Function encrypttwofish:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7fkQ0
function name:  encryptTwofish
number of ops:  59
compiled vars:  !0 = $data, !1 = $key, !2 = $td, !3 = $binaryKey, !4 = $iv, !5 = $encryptedData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  139     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  141     2        DEFINED                                          ~6      'MCRYPT_DEV_URANDOM'
          3        BOOL_NOT                                         ~7      ~6
          4      > JMPZ                                                     ~7, ->9
          5    >   NEW                                              $8      'Exception'
          6        SEND_VAL_EX                                              'The+MCRYPT_DEV_URANDOM+source+is+required+%28PHP+5.3%29.'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $8
  142     9    >   DEFINED                                          ~10     'MCRYPT_TWOFISH'
         10        BOOL_NOT                                         ~11     ~10
         11      > JMPZ                                                     ~11, ->16
         12    >   NEW                                              $12     'Exception'
         13        SEND_VAL_EX                                              'The+MCRYPT_TWOFISH+algorithm+is+required+%28PHP+5.3%29.'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $12
  145    16    >   INIT_FCALL_BY_NAME                                       'mcrypt_module_open'
         17        FETCH_CONSTANT                                   ~14     'MCRYPT_TWOFISH'
         18        SEND_VAL_EX                                              ~14
         19        SEND_VAL_EX                                              ''
         20        FETCH_CONSTANT                                   ~15     'MCRYPT_MODE_CBC'
         21        SEND_VAL_EX                                              ~15
         22        SEND_VAL_EX                                              ''
         23        DO_FCALL                                      0  $16     
         24        ASSIGN                                                   !2, $16
  149    25        INIT_FCALL                                               'hash'
         26        SEND_VAL                                                 'sha256'
         27        SEND_VAR                                                 !1
         28        SEND_VAL                                                 <true>
         29        DO_ICALL                                         $18     
         30        ASSIGN                                                   !3, $18
  152    31        INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         32        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_iv_size'
         33        SEND_VAR_EX                                              !2
         34        DO_FCALL                                      0  $20     
         35        SEND_VAR_NO_REF_EX                                       $20
         36        FETCH_CONSTANT                                   ~21     'MCRYPT_DEV_URANDOM'
         37        SEND_VAL_EX                                              ~21
         38        DO_FCALL                                      0  $22     
         39        ASSIGN                                                   !4, $22
  154    40        INIT_FCALL_BY_NAME                                       'mcrypt_generic_init'
         41        SEND_VAR_EX                                              !2
         42        SEND_VAR_EX                                              !3
         43        SEND_VAR_EX                                              !4
         44        DO_FCALL                                      0          
  155    45        INIT_FCALL_BY_NAME                                       'mcrypt_generic'
         46        SEND_VAR_EX                                              !2
         47        SEND_VAR_EX                                              !0
         48        DO_FCALL                                      0  $25     
         49        ASSIGN                                                   !5, $25
  156    50        INIT_FCALL_BY_NAME                                       'mcrypt_generic_deinit'
         51        SEND_VAR_EX                                              !2
         52        DO_FCALL                                      0          
  157    53        INIT_FCALL_BY_NAME                                       'mcrypt_module_close'
         54        SEND_VAR_EX                                              !2
         55        DO_FCALL                                      0          
  160    56        CONCAT                                           ~29     !4, !5
         57      > RETURN                                                   ~29
  161    58*     > RETURN                                                   null

End of function encrypttwofish

Function decrypttwofish:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7fkQ0
function name:  decryptTwofish
number of ops:  61
compiled vars:  !0 = $encryptedData, !1 = $key, !2 = $td, !3 = $ivSize, !4 = $iv, !5 = $binaryKey, !6 = $decryptedData
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  169     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  171     2        DEFINED                                          ~7      'MCRYPT_TWOFISH'
          3        BOOL_NOT                                         ~8      ~7
          4      > JMPZ                                                     ~8, ->9
          5    >   NEW                                              $9      'Exception'
          6        SEND_VAL_EX                                              'The+MCRYPT_TWOFISH+algorithm+is+required+%28PHP+5.3%29.'
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $9
  173     9    >   INIT_FCALL_BY_NAME                                       'mcrypt_module_open'
         10        FETCH_CONSTANT                                   ~11     'MCRYPT_TWOFISH'
         11        SEND_VAL_EX                                              ~11
         12        SEND_VAL_EX                                              ''
         13        FETCH_CONSTANT                                   ~12     'MCRYPT_MODE_CBC'
         14        SEND_VAL_EX                                              ~12
         15        SEND_VAL_EX                                              ''
         16        DO_FCALL                                      0  $13     
         17        ASSIGN                                                   !2, $13
  176    18        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_iv_size'
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0  $15     
         21        ASSIGN                                                   !3, $15
  177    22        INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 0
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $17     
         27        ASSIGN                                                   !4, $17
  178    28        INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !0
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $19     
         32        ASSIGN                                                   !0, $19
  180    33        INIT_FCALL                                               'hash'
         34        SEND_VAL                                                 'sha256'
         35        SEND_VAR                                                 !1
         36        SEND_VAL                                                 <true>
         37        DO_ICALL                                         $21     
         38        ASSIGN                                                   !5, $21
  182    39        INIT_FCALL_BY_NAME                                       'mcrypt_generic_init'
         40        SEND_VAR_EX                                              !2
         41        SEND_VAR_EX                                              !5
         42        SEND_VAR_EX                                              !4
         43        DO_FCALL                                      0          
  183    44        INIT_FCALL_BY_NAME                                       'mdecrypt_generic'
         45        SEND_VAR_EX                                              !2
         46        SEND_VAR_EX                                              !0
         47        DO_FCALL                                      0  $24     
         48        ASSIGN                                                   !6, $24
  184    49        INIT_FCALL_BY_NAME                                       'mcrypt_generic_deinit'
         50        SEND_VAR_EX                                              !2
         51        DO_FCALL                                      0          
  185    52        INIT_FCALL_BY_NAME                                       'mcrypt_module_close'
         53        SEND_VAR_EX                                              !2
         54        DO_FCALL                                      0          
  188    55        INIT_FCALL                                               'rtrim'
         56        SEND_VAR                                                 !6
         57        SEND_VAL                                                 '%00'
         58        DO_ICALL                                         $28     
         59      > RETURN                                                   $28
  189    60*     > RETURN                                                   null

End of function decrypttwofish

Function calculatetwofishlength:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7fkQ0
function name:  calculateTwofishLength
number of ops:  29
compiled vars:  !0 = $inputLength, !1 = $td, !2 = $ivSize, !3 = $blockSize
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  191     0  E >   RECV                                             !0      
  193     1        INIT_FCALL_BY_NAME                                       'mcrypt_module_open'
          2        FETCH_CONSTANT                                   ~4      'MCRYPT_TWOFISH'
          3        SEND_VAL_EX                                              ~4
          4        SEND_VAL_EX                                              ''
          5        FETCH_CONSTANT                                   ~5      'MCRYPT_MODE_CBC'
          6        SEND_VAL_EX                                              ~5
          7        SEND_VAL_EX                                              ''
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !1, $6
  194    10        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_iv_size'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !2, $8
  195    14        INIT_FCALL_BY_NAME                                       'mcrypt_enc_get_block_size'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $10     
         17        ASSIGN                                                   !3, $10
  196    18        INIT_FCALL_BY_NAME                                       'mcrypt_module_close'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
  197    21        INIT_FCALL                                               'ceil'
         22        DIV                                              ~13     !0, !3
         23        SEND_VAL                                                 ~13
         24        DO_ICALL                                         $14     
         25        MUL                                              ~15     !3, $14
         26        ADD                                              ~16     !2, ~15
         27      > RETURN                                                   ~16
  198    28*     > RETURN                                                   null

End of function calculatetwofishlength

End of class StoPasswordHash.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.08 ms | 1424 KiB | 33 Q