Strength and weaknesses of this JavaScript charCodeAt based login script I know of a company on their website who are using this very basic password login page written in JavaScript. This doesn't seem very secure at all, because in the html source code it shows where the script comes from: http://www.dynamicdrive.com/dynamicindex9/password.htm and also you can see how it works as it's JavaScript and you can just view the source in a browser.

It seem pretty simple, it takes a value entered in an input field by a user works out the char unicode interger value of each character in the passcode and then times this value by the previous value and loops this until it has done this for each character in the passcode. It then compares this with an answer value saved in JavaScript which the user has already converted from the right answer in the same manner using the tool on  http://www.dynamicdrive.com/dynamicindex9/password.htm and then if these two match the JavaScript redirects you to the secret page which is a html file with the same name of the clear text password.

My question is knowing how this method works to convert what the user inputs into a charcode value, how can you reverse this process to find out what the original plain text password was? I have changed the usercode and passcode value below to what is featured on this companys website.

I have thought of two methods to change 16978476480 back to plain text. One possibility I guess would to get a word list of common passwords, convert each to a number value using the same method and then seeing if any match 16978476480. The other similar method would be to pick random characters to form a string between 4 and 8 characters in length, the usual password lengths, times all the unicode values to together and then keep looping until we get lucky and hit a match for 16978476480. Can anyone think of any better of faster ways? 

The script is as follows:

//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive 
//Visit http://www.dynamicdrive.com 

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i &lt; password.length; i++) {
passcode *= password.charCodeAt(i);
}
for(x = 0; x &lt; username.length; x++) {
usercode *= username.charCodeAt(x);
}
//CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
if(usercode==12211815000&amp;&amp;passcode==16978476480)
//CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
{
window.location=password+".html"}
else{
alert("password/username combination wrong")}
}


&lt;form name="password1"&gt;
&lt;strong&gt;Enter username:&lt;/strong&gt;
&lt;input type="text" name="username2" size="15"&gt;
&lt;br&gt;
&lt;strong&gt;Enter password: &lt;/strong&gt;
&lt;input type="password" name="password2" size="15"&gt;

&lt;input type="button" value="Submit" onClick="submitentry()"&gt;
&lt;/form&gt;
You don't need to brute force it. Since the passcode is the product of all its character codes, you can just find all prime factors of the passcode. I used an online tool which yields $2^6\cdot 3\cdot 5\cdot 7^2\cdot 61^2\cdot 97$. It looks like an ASCII passcode of length 5.

This doesn't get you anywhere since this is just a check for a web page to open. Now you need to "brute force" all possible combinations of $2^6\cdot 3\cdot 5\cdot 7^2\cdot 61^2$ ($97$ is more of less fixed to be a) and then try for each combination all permutations. You can further filter a little since only lowercase letters are used. For each permutation you would need to download the password+'.html' file. When you finally get an HTTP 200 code you're done.

Of course if you assume that every letter is lowercase then you can assume that $2\cdot 61$ is z. Now the question is to find a 5 letter word with letter zza in it.... The other prime factors will get you p and i.

Note that you only need to do this for passcode, usercode is not used.