3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // $2a$12$BMxrzFUgKhjg3KYLUxQH7.ewjXzBUiy7MmIICALXHlOYudsAFQnGa $hash = crypt('falcon', '$2a$12$BMxrzFUgKhjg3KYLUxQH7K'); var_dump($hash == crypt('falcon', $hash)); var_dump($hash == '$2a$12$BMxrzFUgKhjg3KYLUxQH7.ewjXzBUiy7MmIICALXHlOYudsAFQnGa'); /* $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 echo $hash = crypt('falcon', '$2a$12$' . $salt); var_dump('$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 */
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(true) bool(true)
Output for 4.3.0 - 5.2.17

Process exited with code 139.