php code md5 hashing explanation
<p>I am working with the moodle system, but it turns out that it uses md5 salt hashing. I found some come, so maybe you could explaint it to me because I am have only basic knowledge of php.</p>

<pre><code>function validate_internal_user_password($user, $password) {
global $CFG;

if (!isset($CFG-&gt;passwordsaltmain)) {
    $CFG-&gt;passwordsaltmain = '';
}

$validated = false;

if ($user-&gt;password === 'not cached') {
    // internal password is not used at all, it can not validate

} else if ($user-&gt;password === md5($password.$CFG-&gt;passwordsaltmain)
        or $user-&gt;password === md5($password)
        or $user-&gt;password === md5(addslashes($password).$CFG-&gt;passwordsaltmain)
        or $user-&gt;password === md5(addslashes($password))) {
    // note: we are intentionally using the addslashes() here because we
    //       need to accept old password hashes of passwords with magic quotes
    $validated = true;

} else {
    for ($i=1; $i&lt;=20; $i++) { //20 alternative salts should be enough, right?
        $alt = 'passwordsaltalt'.$i;
        if (!empty($CFG-&gt;$alt)) {
            if ($user-&gt;password === md5($password.$CFG-&gt;$alt) or $user-&gt;password === md5(addslashes($password).$CFG-&gt;$alt)) {
                $validated = true;
                break;
            }
        }
    }
}

if ($validated) {
    // force update of password hash using latest main password salt and encoding if needed
    update_internal_user_password($user, $password);
}

return $validated;
</code></pre>

<p>}</p>

<p>Would it be hard to change it that after entering simple text it would became hashed?</p>
