function md5($string) {
    // Initialize variables
    $a0 = 0x67452301;
    $b0 = 0xefcdab89;
    $c0 = 0x98badcfe;
    $d0 = 0x10325476;

    // Pre-processing
    $string = pad($string);
    $length = strlen($string) * 8;

    // Process the message in 512-bit chunks
    for ($i = 0; $i < $length; $i += 512) {
        $words = array();
        for ($j = 0; $j < 16; $j++) {
            $words[$j] = ord($string[$i + $j * 4]) |
                         (ord($string[$i + $j * 4 + 1]) << 8) |
                         (ord($string[$i + $j * 4 + 2]) << 16) |
                         (ord($string[$i + $j * 4 + 3]) << 24);
        }

        $a = $a0;
        $b = $b0;
        $c = $c0;
        $d = $d0;

        // ... (Main Loop: The 4 rounds you've written, truncated here for brevity) ...

        $a0 += $a;
        $b0 += $b;
        $c0 += $c;
        $d0 += $d;
    }

    return sprintf('%08x%08x%08x%08x', $a0, $b0, $c0, $d0);
}

function pad($string) {
    $original_len = strlen($string);
    $string .= chr(0x80);
    while (strlen($string) % 64 !== 56) {
        $string .= chr(0x00);
    }
    $string .= pack('V*', $original_len * 8, ($original_len * 8) >> 32);
    return $string;
}

function F($x, $y, $z) {
    return ($x & $y) | (~$x & $z);
}

function G($x, $y, $z) {
    return ($x & $z) | ($y & ~$z);
}

function H($x, $y, $z) {
    return $x ^ $y ^ $z;
}

function I($x, $y, $z) {
    return $y ^ ($x | ~$z);
}

function md5LeftRotate($x, $n) {
    return ($x << $n) | ($x >> (32 - $n));
}

// Test the MD5 function
$password = "secure_password";
echo md5($password);







function bcrypt_hash($password, $cost = 10) {
  $hash = password_hash($password, PASSWORD_BCRYPT, ['cost' => $cost]);
  return $hash;
}

function bcrypt_verify($password, $hash) {
  return password_verify($password, $hash);
}





__________________________________________________________________

------------------------------------------------------------------
                    custom_hash.php
------------------------------------------------------------------
function custom_hash($password, $salt) {
    $hashed = hash('sha256', $salt . $password);
    for ($i = 0; $i < 1000; $i++) {
        $hashed = hash('sha256', $hashed);
    }
    return $hashed;
}

-------------------------------------------------------------------
                register.php
--------------------------------------------------------------------
<?php
include 'custom_hash.php'; // Assuming the custom hash function is saved in this file

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $salt = bin2hex(random_bytes(16));
    $hashed_password = custom_hash($password, $salt);

    $db = sqlite_open('/tmp/demo.db');
    $query = "INSERT INTO users (username, password_hash, salt) VALUES ('$username', '$hashed_password', '$salt')";
    sqlite_query($db, $query);
    sqlite_close($db);

    echo "Registration Successful!";
}

?>

<form method="post">
    Username: <input type="text" name="username" required>
    Password: <input type="password" name="password" required>
    <input type="submit" value="Register">
</form>

--------------------------------------------------------------------
                        login.php
--------------------------------------------------------------------
<?php
include 'custom_hash.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];

    $db = sqlite_open('/tmp/demo.db');
    $result = sqlite_query($db, "SELECT password_hash, salt FROM users WHERE username = '$username'");
    $row = sqlite_fetch_array($result);

    if ($row) {
        $stored_hashed_password = $row['password_hash'];
        $stored_salt = $row['salt'];

        $hashed_password_attempt = custom_hash($password, $stored_salt);

        if ($hashed_password_attempt === $stored_hashed_password) {
            echo "Login Successful!";
        } else {
            echo "Incorrect password!";
        }
    } else {
        echo "User not found!";
    }
    
    sqlite_close($db);
}

?>

<form method="post">
    Username: <input type="text" name="username" required>
    Password: <input type="password" name="password" required>
    <input type="submit" value="Login">
</form>




__________________________________________________________________