3v4l.org

run code in 300+ PHP versions simultaneously
<?php function createPasswordHash($strPassword, $numAlgo = 1, $arrOptions = array()) { if (function_exists('password_hash1')) { // php >= 5.5 $hash = password_hash($strPassword, $numAlgo, $arrOptions); } else { $salt = mcrypt_create_iv(22, MCRYPT_DEV_URANDOM); $salt = base64_encode($salt); $salt = str_replace('+', '.', $salt); $hash = crypt($strPassword, '$2y$10$' . $salt . '$'); } return $hash; } function verifyPasswordHash($strPassword, $strHash) { if (function_exists('password_verify1')) { // php >= 5.5 $boolReturn = password_verify($strPassword, $strHash); } else { $strHash2 = crypt($strPassword, $strHash); $boolReturn = $strHash == $strHash2; } return $boolReturn; } $strHash = createPasswordHash("sunshine", PASSWORD_DEFAULT); echo $strHash . "<br>\n"; if (verifyPasswordHash('sunshine', $strHash)) { echo 'Password is valid!'; } else { echo 'Invalid password.'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Laqar
function name:  (null)
number of ops:  16
compiled vars:  !0 = $strHash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'createpasswordhash'
          1        SEND_VAL                                                 'sunshine'
          2        SEND_VAL                                                 '2y'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   30     5        CONCAT                                           ~3      !0, '%3Cbr%3E%0A'
          6        ECHO                                                     ~3
   32     7        INIT_FCALL                                               'verifypasswordhash'
          8        SEND_VAL                                                 'sunshine'
          9        SEND_VAR                                                 !0
         10        DO_FCALL                                      0  $4      
         11      > JMPZ                                                     $4, ->14
   33    12    >   ECHO                                                     'Password+is+valid%21'
         13      > JMP                                                      ->15
   35    14    >   ECHO                                                     'Invalid+password.'
   36    15    > > RETURN                                                   1

Function createpasswordhash:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Laqar
function name:  createPasswordHash
number of ops:  39
compiled vars:  !0 = $strPassword, !1 = $numAlgo, !2 = $arrOptions, !3 = $hash, !4 = $salt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      1
          2        RECV_INIT                                        !2      <array>
    5     3        INIT_FCALL                                               'function_exists'
          4        SEND_VAL                                                 'password_hash1'
          5        DO_ICALL                                         $5      
          6      > JMPZ                                                     $5, ->14
    7     7    >   INIT_FCALL                                               'password_hash'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !3, $6
         13      > JMP                                                      ->37
    9    14    >   INIT_FCALL_BY_NAME                                       'mcrypt_create_iv'
         15        SEND_VAL_EX                                              22
         16        FETCH_CONSTANT                                   ~8      'MCRYPT_DEV_URANDOM'
         17        SEND_VAL_EX                                              ~8
         18        DO_FCALL                                      0  $9      
         19        ASSIGN                                                   !4, $9
   10    20        INIT_FCALL                                               'base64_encode'
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                         $11     
         23        ASSIGN                                                   !4, $11
   11    24        INIT_FCALL                                               'str_replace'
         25        SEND_VAL                                                 '%2B'
         26        SEND_VAL                                                 '.'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                         $13     
         29        ASSIGN                                                   !4, $13
   12    30        INIT_FCALL                                               'crypt'
         31        SEND_VAR                                                 !0
         32        CONCAT                                           ~15     '%242y%2410%24', !4
         33        CONCAT                                           ~16     ~15, '%24'
         34        SEND_VAL                                                 ~16
         35        DO_ICALL                                         $17     
         36        ASSIGN                                                   !3, $17
   14    37    > > RETURN                                                   !3
   15    38*     > RETURN                                                   null

End of function createpasswordhash

Function verifypasswordhash:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
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: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Laqar
function name:  verifyPasswordHash
number of ops:  21
compiled vars:  !0 = $strPassword, !1 = $strHash, !2 = $boolReturn, !3 = $strHash2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        INIT_FCALL                                               'function_exists'
          3        SEND_VAL                                                 'password_verify1'
          4        DO_ICALL                                         $4      
          5      > JMPZ                                                     $4, ->12
   21     6    >   INIT_FCALL                                               'password_verify'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $5      
         10        ASSIGN                                                   !2, $5
         11      > JMP                                                      ->19
   23    12    >   INIT_FCALL                                               'crypt'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $7      
         16        ASSIGN                                                   !3, $7
   24    17        IS_EQUAL                                         ~9      !1, !3
         18        ASSIGN                                                   !2, ~9
   26    19    > > RETURN                                                   !2
   27    20*     > RETURN                                                   null

End of function verifypasswordhash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.67 ms | 1407 KiB | 27 Q