3v4l.org

run code in 300+ PHP versions simultaneously
<?php $password = "chemicals1"; $expected = "{SSHA512}w/lHn2LXfNletbfyLVYutBFqUjGPzhmptyleVlehUZSZdylZCt/sDmvkhTBV1Ln4f6rzXTdM6eOGr3LX7FgGCF5/fsbs0vVq"; function compare_postfix_ssha512_hash($password, $valid_hash) { $hash_algo = "{SSHA512}"; $salt_length = 8; // strip the identifier from the hash (if exists) $valid_hash = str_replace($hash_algo, "", $valid_hash); // get the salt from the valid hash $salt = substr(base64_decode($valid_hash), -$salt_length); // strip the salt from the end of the valid hash $valid_hash = base64_encode(substr(base64_decode($valid_hash), 0, -$salt_length)); // hash our password with the salt $hash = base64_encode(hash('sha512', "{$password}{$salt}", true)); // return the comparison return hash_equals($valid_hash, $hash); } var_dump(compare_postfix_ssha512_hash($password, $expected));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PsLij
function name:  (null)
number of ops:  10
compiled vars:  !0 = $password, !1 = $expected
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'chemicals1'
    4     1        ASSIGN                                                   !1, '%7BSSHA512%7Dw%2FlHn2LXfNletbfyLVYutBFqUjGPzhmptyleVlehUZSZdylZCt%2FsDmvkhTBV1Ln4f6rzXTdM6eOGr3LX7FgGCF5%2Ffsbs0vVq'
   26     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'compare_postfix_ssha512_hash'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function compare_postfix_ssha512_hash:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PsLij
function name:  compare_postfix_ssha512_hash
number of ops:  49
compiled vars:  !0 = $password, !1 = $valid_hash, !2 = $hash_algo, !3 = $salt_length, !4 = $salt, !5 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        ASSIGN                                                   !2, '%7BSSHA512%7D'
    8     3        ASSIGN                                                   !3, 8
   11     4        INIT_FCALL                                               'str_replace'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 ''
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !1, $8
   14    10        INIT_FCALL                                               'substr'
         11        INIT_FCALL                                               'base64_decode'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        MUL                                              ~11     !3, -1
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !4, $12
   17    19        INIT_FCALL                                               'base64_encode'
         20        INIT_FCALL                                               'substr'
         21        INIT_FCALL                                               'base64_decode'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $14     
         24        SEND_VAR                                                 $14
         25        SEND_VAL                                                 0
         26        MUL                                              ~15     !3, -1
         27        SEND_VAL                                                 ~15
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                         $17     
         31        ASSIGN                                                   !1, $17
   20    32        INIT_FCALL                                               'base64_encode'
         33        INIT_FCALL                                               'hash'
         34        SEND_VAL                                                 'sha512'
         35        NOP                                                      
         36        FAST_CONCAT                                      ~19     !0, !4
         37        SEND_VAL                                                 ~19
         38        SEND_VAL                                                 <true>
         39        DO_ICALL                                         $20     
         40        SEND_VAR                                                 $20
         41        DO_ICALL                                         $21     
         42        ASSIGN                                                   !5, $21
   23    43        INIT_FCALL                                               'hash_equals'
         44        SEND_VAR                                                 !1
         45        SEND_VAR                                                 !5
         46        DO_ICALL                                         $23     
         47      > RETURN                                                   $23
   24    48*     > RETURN                                                   null

End of function compare_postfix_ssha512_hash

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.25 ms | 1403 KiB | 28 Q