md5() Returns a 32 Digit Hexadecimal Value

Un-Hashed: Slooby83

Hashed: 0a77a37b20b72aac1b29b8dfa14a1139

Double Hashed: f5c255166cf4b0014d34f3ba211dd9c7


Try it Yourself!



The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>PHP: MD5</title>
</head>
<body>

<h1 class="lesson-h1">md5() Returns a 32 Digit Hexadecimal Value</h1>

    <?php
        $password = "Slooby83";
        echo "<p><strong>Un-Hashed: </strong>$password</p>";

        $hashed_password = md5($password);
        echo "<p><strong>Hashed: </strong>$hashed_password</p>";

        $hashed_password = md5(md5($password));
        echo "<p><strong>Double Hashed: </strong>$hashed_password</p><hr>";

        if(isset($_POST["user-password"])){
            $user_password = htmlentities($_POST['user-password']);
            if(!$user_password){
                echo $bugle = new Error("La Cagas: #021: <p><strong>Password Field is Empty</strong></p><p><a href='index.php'>Go Back</a></p>");
                exit;
            } else {
                $hashed = md5($user_password);
                $double_hashed = md5($hashed);
                echo "<p><Strong>" . $user_password . "</strong>" . " Hashes Into: <strong>" . $hashed . "</strong></p>"; 
                echo "<p><Strong>" . $user_password . "</strong>" . " Double Hashes Into: <strong>" . $double_hashed . "</strong></p>"; 
            }
        }

    ?>
    <p>Try it Yourself!</p>
    <form action="index.php" method="post">
        <input type="text" name="user-password" id="user-password" placeholder="Enter a Password">
        <input type="submit" value="Submit">
    </form>
    <hr>
    <?php
        include('../show_code.php');
        show_code('index.php');
    ?>    
</body>
</html>