Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Jul 2008
Posts: 396
Reputation: leegeorg07 is an unknown quantity at this point 
Solved Threads: 31
leegeorg07's Avatar
leegeorg07 leegeorg07 is offline Offline
Posting Whiz

encrypt/decrypt

 
0
  #1
Oct 10th, 2009
Hi, using a snippet I found on here I have this code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var password;
  2. var pass1="PASSWORD-HERE";
  3. password=prompt('Whats The Magic Word?',' ');
  4. if (password==pass1) alert('That Is Correct!');
  5. else {
  6. window.location="SITE-LINK";
  7. }
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?
don't judge me because I'm a year 8!

'it is better to fight for something than to live for nothing'General George S Patton
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 24
Reputation: HenryGR is an unknown quantity at this point 
Solved Threads: 3
HenryGR's Avatar
HenryGR HenryGR is offline Offline
Newbie Poster
 
0
  #2
Oct 21st, 2009
Originally Posted by leegeorg07 View Post
Hi, using a snippet I found on here I have this code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. var password;
  2. var pass1="PASSWORD-HERE";
  3. password=prompt('Whats The Magic Word?',' ');
  4. if (password==pass1) alert('That Is Correct!');
  5. else {
  6. window.location="SITE-LINK";
  7. }
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.
You keep going, have a Nice day!
Henry.

Before printing this message, make sure is necessary.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC