3v4l.org

run code in 300+ PHP versions simultaneously
<?php $salt = substr(str_replace('+', '.', base64_encode(sha1(microtime(true), true))), 0, 22); // 2a is the bcrypt algorithm selector, see http://php.net/crypt // 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt $hash = crypt('falcon', '$2a$12$' . $salt); // we can now use the generated hash as the argument to crypt(), since it too will contain $a2$12$... with a variation of the hash. No need to store the salt anymore, just the hash is enough! var_dump($hash == crypt('foo', $hash)); // true var_dump($hash == crypt('falcon', $hash)); // false
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sqDcX
function name:  (null)
number of ops:  44
compiled vars:  !0 = $salt, !1 = $hash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'substr'
          1        INIT_FCALL                                               'str_replace'
          2        SEND_VAL                                                 '%2B'
          3        SEND_VAL                                                 '.'
          4        INIT_FCALL                                               'base64_encode'
          5        INIT_FCALL                                               'sha1'
          6        INIT_FCALL                                               'microtime'
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $3      
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
         15        DO_ICALL                                         $5      
         16        SEND_VAR                                                 $5
         17        SEND_VAL                                                 0
         18        SEND_VAL                                                 22
         19        DO_ICALL                                         $6      
         20        ASSIGN                                                   !0, $6
    7    21        INIT_FCALL                                               'crypt'
         22        SEND_VAL                                                 'falcon'
         23        CONCAT                                           ~8      '%242a%2412%24', !0
         24        SEND_VAL                                                 ~8
         25        DO_ICALL                                         $9      
         26        ASSIGN                                                   !1, $9
   10    27        INIT_FCALL                                               'var_dump'
         28        INIT_FCALL                                               'crypt'
         29        SEND_VAL                                                 'foo'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                         $11     
         32        IS_EQUAL                                         ~12     !1, $11
         33        SEND_VAL                                                 ~12
         34        DO_ICALL                                                 
   11    35        INIT_FCALL                                               'var_dump'
         36        INIT_FCALL                                               'crypt'
         37        SEND_VAL                                                 'falcon'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                         $14     
         40        IS_EQUAL                                         ~15     !1, $14
         41        SEND_VAL                                                 ~15
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.08 ms | 1396 KiB | 27 Q