Results 1 to 2 of 2

Thread: help needed javascript encripted password form

  1. #1
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help needed javascript encripted password form

    hi im using a encrypted password script, im new to javascript, ive set four users, it works fine and forwards correctly, however on all but one password teven though the password works and forwards to a url the alert box appears, i cant work out why!.

    also a simple one i want the submit button to be horizontally inline with the input box.

    The passwords are:

    john

    james

    tim

    phil

    The script ive used is below, many thanks.

    Code:
    <script>
    //Encrypted Password script- By Rob Heslop
    //Script featured on Dynamic Drive 
    //Visit http://www.dynamicdrive.com 
    
    
    function submitentry(){
    password = document.password1.password2.value.toLowerCase()
    
    passcode = 1
    for(i = 0; i < password.length; i++) {
    passcode *= password.charCodeAt(i);
    }
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(passcode==134603040)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.google.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(passcode==13017371870)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.yahoo.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(passcode==132088320)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.ebay.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(passcode==1327620)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.hotmail.com"}
    
    else{
    alert("EITHER: Passcode incorrect.")}
    }
    </script>
    
    <form name="password1">
    
    <input type="password" name="password2" size="15">
    
    <input type="button" value="Submit" onClick="submitentry()">
    </form>
    Last edited by jscheuer1; 10-28-2011 at 03:53 PM. Reason: format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    First off this provides like Zero security. Anyone can look at the source code and see the destinations and navigate directly to them.

    But to answer your question, you need to make all but the first if else if:

    Code:
    //Encrypted Password script- By Rob Heslop
    //Script featured on Dynamic Drive 
    //Visit http://www.dynamicdrive.com 
    
    
    function submitentry(){
    password = document.password1.password2.value.toLowerCase()
    
    passcode = 1
    for(i = 0; i < password.length; i++) {
    passcode *= password.charCodeAt(i);
    }
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(passcode==134603040)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.google.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    else if(passcode==13017371870)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.yahoo.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    else if(passcode==132088320)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.ebay.com"}
    
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    else if(passcode==1327620)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    window.location="http://www.hotmail.com"}
    
    else{
    alert("EITHER: Passcode incorrect.")}
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •