3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasher($info, $encdata = false) { $strength = "08"; //if encrypted data is passed, check it against input ($info) if ($encdata) { if (substr($encdata, 0, 60) == crypt($info, "$2a$".$strength."$".substr($encdata, 60))) { return true; } else { return false; } } else { //make a salt and hash it with input, and add salt to end $salt = ""; for ($i = 0; $i < 22; $i++) { $salt .= substr("./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", mt_rand(0, 63), 1); } //return 82 char string (60 char hash & 22 char salt) return crypt($info, "$2a$".$strength."$".$salt).$salt; } } if ('$2a$08$EtdOmTznraimrGNl0uZiPecrPugD5HeOc4yAGd.Kx/gx2vmCUmC7SEtdOmTznraimrGNl0uZiPl' == hasher('tylko', '$2a$08$EtdOmTznraimrGNl0uZiPecrPugD5HeOc4yAGd.Kx/gx2vmCUmC7SEtdOmTznraimrGNl0uZiPl')) { echo 'sss'; }
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17

Process exited with code 139.

preferences:
169.22 ms | 402 KiB | 220 Q