java script to encrypt login password

Glen Davies GLEN at rimu.cce.ac.nz
Wed Oct 15 18:09:43 EDT 1997


Hi

something that may be of use to somebody - a java script that will 
decode a password to automatically login on to a web service that 
requires user id and password verification. It is not secure by any 
means, but is one step away from having your passwords  easily veiwable 
in your html code. Good for those sites that aren't really secure but 
require you to log on anyway, but for which you don't want users having to 
enter login details or knowing the Library's id to use from home. It 
could  be easily cracked by a programmer though. All the user has to do 
to login is click a button, no user id and password boxes are 
visible. 

I have set it up for an electronic journal sub we have and 
it seems to work fine. The example below is purly fictional though, 
the form actions etc need to be replaced with valid ones.

All it does when the user clicks the login in button is take 
each character  of the form input named "input" and change it to the 
character to the right of it in the variable "ref". So in the 
following example "agovx"  becomes "henry" . It then returns this 
value to the input field named pw.  

I'm just a beginner at java script so probably can't be of much help 
if it doesn't work for you. Have a look at the javascript  tutorial 
at http://www.webteacher.com/  This is were I got the basic code 
from.



<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

function encode(text) { 

     Ref="1923786540chikjmonpqstuvrxydahgei"
     Result=""
     for (Count=0; Count<text.length; Count++) {

          Char=text.substring (Count, Count+1);
          Num=Ref.indexOf (Char);
          EncodeChar=Ref.substring(Num+1, Num+2)
          Result += EncodeChar

     }

document.form1.pw.value=Result
}

// - End of JavaScript - -->
</SCRIPT>

</HEAD>

<FORM name="form1" METHOD=POST 
ACTION=http://www.goodstuff.com/cgi-bin/signon>
<INPUT NAME="input" TYPE=hidden value="agovx"><br>
<INPUT TYPE="hidden" NAME=code value="daviesg" SIZE=15>
<INPUT TYPE="hidden" NAME=pw  SIZE=15>
<INPUT TYPE=Submit VALUE="login to electronic journals"
onClick="encode(this.form.input.value)">

</FORM>
***********************************************************
Glen Davies
Information Technology Librarian
Christchurch College of Education
Christchurch
New Zealand
glen at rimu.cce.ac.nz
64-3-343 7737
************************************************************
"I've been drunk for about a week now, and I thought it might
 sober me up to sit in a library" F.Scott Fitzgerald
                                  The Great Gatsby, ch3
************************************************************


More information about the Web4lib mailing list