Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I protect my password on the website?

On the site, the login is made using a code of the type if the entered password matches the variable in which the password is stored, then the person enters the site. How to protect the site from the magic F12 button? I.e. how to make the password impossible to find
out

p.s. I have never done anything like this so the experience is 0.

I wrote the code and don’t know how to protect passwords.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

function checkUsernamePassword() {
    var username = document.getElementById("username").value;
    var password = document.getElementById("password").value;

    if (username == "admin" && password == "12345") {
        window.location = "../index.html";
    }
    else {
        window.location = "invalid-login.html";
    }
}

>Solution :

Ordinarily, your approach would be easily bypassed.

However, with the WebCrypto API you can use strong encryption to protect the data that needs to be accessed with a password.

You’d use a salted PBKDF2 to stretch the password into a symmetric encryption key. Then, the data can only be accessed when the correct password is entered.

This approach relies on the password being of sufficient entropy to prevent a brute-force attack.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading