3v4l.org

run code in 300+ PHP versions simultaneously
<?php class passwordHash { // blowfish private static $algo = '$2a'; // cost parameter private static $cost = '$10'; // mainly for internal use public static function unique_salt() { return substr(sha1(mt_rand()), 0, 22); } // this will be used to generate a hash public static function hash($password) { return crypt($password, self::$algo . self::$cost . '$' . self::unique_salt()); } // this will be used to compare a password against a hash public static function check_password($hash, $password) { $full_salt = substr($hash, 0, 29); $new_hash = crypt($password, $full_salt); return ($hash == $new_hash); } } $pw = 'test'; print( passwordHash::hash($pw) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vddob
function name:  (null)
number of ops:  6
compiled vars:  !0 = $pw
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, 'test'
   33     1        INIT_STATIC_METHOD_CALL                                  'passwordHash', 'hash'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Class passwordHash:
Function unique_salt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vddob
function name:  unique_salt
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'substr'
          1        INIT_FCALL                                               'sha1'
          2        INIT_FCALL                                               'mt_rand'
          3        DO_ICALL                                         $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        SEND_VAL                                                 0
          8        SEND_VAL                                                 22
          9        DO_ICALL                                         $2      
         10      > RETURN                                                   $2
   13    11*     > RETURN                                                   null

End of function unique_salt

Function hash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vddob
function name:  hash
number of ops:  14
compiled vars:  !0 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        INIT_FCALL                                               'crypt'
          2        SEND_VAR                                                 !0
          3        FETCH_STATIC_PROP_R          global lock         ~1      'algo'
   19     4        FETCH_STATIC_PROP_R          unknown             ~2      'cost'
          5        CONCAT                                           ~3      ~1, ~2
   20     6        CONCAT                                           ~4      ~3, '%24'
          7        INIT_STATIC_METHOD_CALL                                  'unique_salt'
          8        DO_FCALL                                      0  $5      
          9        CONCAT                                           ~6      ~4, $5
         10        SEND_VAL                                                 ~6
   18    11        DO_ICALL                                         $7      
   20    12      > RETURN                                                   $7
   21    13*     > RETURN                                                   null

End of function hash

Function check_password:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vddob
function name:  check_password
number of ops:  16
compiled vars:  !0 = $hash, !1 = $password, !2 = $full_salt, !3 = $new_hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 29
          6        DO_ICALL                                         $4      
          7        ASSIGN                                                   !2, $4
   26     8        INIT_FCALL                                               'crypt'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $6      
         12        ASSIGN                                                   !3, $6
   27    13        IS_EQUAL                                         ~8      !0, !3
         14      > RETURN                                                   ~8
   28    15*     > RETURN                                                   null

End of function check_password

End of class passwordHash.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.74 ms | 1008 KiB | 17 Q