Member Avatar for leegeorg07

Hi, using a snippet I found on here I have this code:

var password;
var pass1="PASSWORD-HERE";
password=prompt('Whats The Magic Word?',' ');
if (password==pass1) alert('That Is Correct!');
else {
  window.location="SITE-LINK";
}

But I want to make pass1 harder to see so I want to encrypt it and use that as the var. Then I want to decrypt it at the if so that it is harder to be used to access secure information. How would I go about doing this?

Hi, using a snippet I found on here I have this code:

var password;
var pass1="PASSWORD-HERE";
password=prompt('Whats The Magic Word?',' ');
if (password==pass1) alert('That Is Correct!');
else {
  window.location="SITE-LINK";
}

But I want to make pass1 harder to see so I want to encrypt it and use that as the var. Then I want to decrypt it at the if so that it is harder to be used to access secure information. How would I go about doing this?

Well, on a first place, I would never try to use Javascript for a password protected business, but if you have to, create the code and, once finished, try to obfuscate the whole, instead of a single variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.