Password Security Project in Javascript

Ask questions about projects relating to: computer science or pure mathematics (such as probability, statistics, geometry, etc...).

Moderators: kgudger, bfinio, Moderators

Locked
baseballdragon9
Posts: 4
Joined: Wed Jan 29, 2014 4:20 pm
Occupation: Student: grade 9
Project Question: To get help with my project.
Project Due Date: November 15, 2014
Project Status: Not applicable

Password Security Project in Javascript

Post by baseballdragon9 »

I am trying to do a variation on this project https://www.sciencebuddies.org/science- ... p046.shtml

I don't know python, so I am trying to create something similar with javascript, which I only know the basics of. The program I am working on will not actually hack into anything, it just gives you an idea of how long it would take a computer to guess an unencrypted password that someone might use. It has the user enter a password, then use brute force to guess all possibilities for each character in the password, and then print out the time it took to guess.

I am not sure how to set up the function at the bottom so that it loops through all of the possible characters.
Should it look something like this?
var x =0
var y =0
while (Passlength>=x) {
if (y<Guesses.length) {
y++
}
if
(Passcode.charAt(x) != [y])
{
y++
}
x++
}

Or this?
for(var x=0;x<Passlength;x+=1){
for(var y=0;y<Guesses.length;y+=1){
if(Passcode.charAt(x) == Guesses[y]){
Passcode += [y];

If anyone knows javascript and could help me out, that would be fantastic! Here is what I have so far.

Code: Select all

var Passcode = prompt("Enter Password");
var Passlength = Passcode.length;
console.time ("GuessTime");

var Guesses = [ "e","a","r","o","n","i","s","t","l","c","d","m","h","u","b","g","p","y","1","k","f","w","2","v","j","3","z","0","x","4","5","9","6","7","8","q","E","A","R","O","N","I","S","T","L","C","D","M","H","U","B","G","P","Y","K","F","W","V","J","Z","X","Q","!","@","#","$","%","^","*","(",")","?","/","<",">","+","=","-","_",
];


for(var x=0;x<Passlength;x+=1){
for(var y=0;y<Guesses.length;y+=1){
if(Passcode.charAt(x) == Guesses[y]){
 Passcode += [y];
}
}
}
document.write (console.timeEnd ("GuessTime"));

dcnick96
Former Expert
Posts: 533
Joined: Wed Jul 25, 2007 7:59 pm

Re: Password Security Project in Javascript

Post by dcnick96 »

Hello. I'm afraid I am not adept in Java, but I wanted to point something out in your outline. You are assuming that you will know beforehand how long the password is. This usually isn't the case. Do you need to write your code so that it tries all lengths (perhaps up to 8 letters) of possible passwords?

Cheers,
Deana
baseballdragon9
Posts: 4
Joined: Wed Jan 29, 2014 4:20 pm
Occupation: Student: grade 9
Project Question: To get help with my project.
Project Due Date: November 15, 2014
Project Status: Not applicable

Re: Password Security Project in Javascript

Post by baseballdragon9 »

It should work for all password lengths. It has the user input a password and saves it as a variable, and from there it creates a second variable called passlength, which is the length of the password .
Locked

Return to “Grades 9-12: Math and Computer Science”