public static function compare($input, $hash, $isHash = false)
    {
        $version = substr($hash, 0, 8);

        if ($isHash === true) {
            return $input == $hash;
        } elseif ($version == 'PBKDF2v1') { // salted PBKDF2
            return PBKDF2::compare($input, $hash);
        } elseif (strlen($hash) == 40) { // legacy, unsalted SHA1
            return SHA1::compare($input, $hash);
        } elseif (strlen($hash) == 32) { // legacy, unsalted MD5
            return MD5::compare($input, $hash);
        } else { // the hash provided doesn't make any sense
            return false;
        }
    }