3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rehashPassword($password, $hash) { if (password_needs_rehash($hash, PASSWORD_BCRYPT,['cost' => 12])) { // 計算コスト12で再ハッシュ化の必要があるかチェック echo 'パスワードを再ハッシュするよ!' . "\n"; $hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]); // 計算コスト12で再度ハッシュ化する // DBに保存しなおしとかそういう処理 } else { echo 'パスワードの再ハッシュは不要だよ!' . "\n"; } return $hash; } $password = 'GoemonLets5'; // パスワード $hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => 11]); // 計算コスト11でハッシュ化する $hash = rehashPassword($password, $hash); // コスト11で暗号化されたハッシュに対してコスト12で暗合されているかチェックをかける $hash = rehashPassword($password, $hash); // 直前の処理でハッシュはコスト12に再計算されているので、再ハッシュは不要になる
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XoO4r
function name:  (null)
number of ops:  18
compiled vars:  !0 = $password, !1 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, 'GoemonLets5'
   17     1        INIT_FCALL                                               'password_hash'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '2y'
          4        SEND_VAL                                                 <array>
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   19     7        INIT_FCALL                                               'rehashpassword'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        DO_FCALL                                      0  $5      
         11        ASSIGN                                                   !1, $5
   21    12        INIT_FCALL                                               'rehashpassword'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_FCALL                                      0  $7      
         16        ASSIGN                                                   !1, $7
         17      > RETURN                                                   1

Function rehashpassword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XoO4r
function name:  rehashPassword
number of ops:  19
compiled vars:  !0 = $password, !1 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'password_needs_rehash'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '2y'
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $2      
          7      > JMPZ                                                     $2, ->16
    6     8    >   ECHO                                                     '%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%82%92%E5%86%8D%E3%83%8F%E3%83%83%E3%82%B7%E3%83%A5%E3%81%99%E3%82%8B%E3%82%88%EF%BC%81%0A'
    7     9        INIT_FCALL                                               'password_hash'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 '2y'
         12        SEND_VAL                                                 <array>
         13        DO_ICALL                                         $3      
         14        ASSIGN                                                   !1, $3
         15      > JMP                                                      ->17
   10    16    >   ECHO                                                     '%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%81%AE%E5%86%8D%E3%83%8F%E3%83%83%E3%82%B7%E3%83%A5%E3%81%AF%E4%B8%8D%E8%A6%81%E3%81%A0%E3%82%88%EF%BC%81%0A'
   12    17    > > RETURN                                                   !1
   13    18*     > RETURN                                                   null

End of function rehashpassword

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.15 ms | 1403 KiB | 19 Q