www.webdeveloper.com
Results 1 to 3 of 3

Thread: accessing a txt file for password varification

  1. #1
    Join Date
    Dec 2010
    Posts
    2

    accessing a txt file for password varification

    hey guys, im having a bit of a metal block here... i need to know how to verify a password from a txt file... i just need to know how to reference it.

    i want it to look something like this:

    <script>
    var password = prompt("Password?")

    if(password == "password from txt file")
    {
    alert("well done!")
    }
    else
    {
    alert("try again")
    }

    </script>

    im not planing to use this, dont worry lol. i know its incredible bad from a security point of view. im using this example for a college essay.

    thanks
    Bowen

  2. #2
    Join Date
    Dec 2010
    Location
    Knoxville, Tn
    Posts
    22
    As described in this post, you can open and read the remote file like this:
    Code:
    var txtFile = new XMLHttpRequest();
    txtFile.open("GET", "http://my.remote.url/myremotefile.txt", true);
    txtFile.onreadystatechange = function() {
    &#160;&#160;if (txtFile.readyState === 4) {&#160; // Makes sure the document is ready to parse.
    &#160;&#160;&#160;&#160;if (txtFile.status === 200) {&#160; // Makes sure it's found the file.
    &#160;&#160;&#160;&#160;&#160; allText = txtFile.responseText; 
    &#160;&#160;&#160;&#160;&#160; lines = txtFile.responseText.split("\n"); // Will separate each line into an array
    &#160;&#160;&#160; }
    &#160; }
    }
    txtFile.send(null);
    which will store all of the files contents in the "allText" variable and an array split up line by line in the "lines" array variable. Then you would need to parse that contents for the password to be tested and test it (unless the password stands alone as the entire contents of the file, it which case, your parsing is done already).

  3. #3
    Join Date
    Dec 2010
    Location
    Knoxville, Tn
    Posts
    22
    Sorry- forgot the link to the source post.. it's here.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles