Page 1 of 1

Password Security Project in Javascript

Posted: Sun Nov 02, 2014 10:30 am
by deleted-126647
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"));


Re: Password Security Project in Javascript

Posted: Sun Nov 02, 2014 8:14 pm
by deleted-71603
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,

Re: Password Security Project in Javascript

Posted: Mon Nov 03, 2014 4:30 am
by deleted-126647
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 .