Hello,

I am a JSP newbie. I am trying to encode a password on a login form, before it is sent to the server. I created a test button to display the hashed password, but errors out with the message 'digestPswd not defined'

Here are the code snippits that I using to implement this functionality:

<webuijsf:head id="head1" title="Log In">
                    <script language='javascript' src='short_sha1.js' type='text/javascript'></script>
                    <script type='text/javascript' language='javascript'>
                         function digestPswd(){
                            var pswdField = document.getElementById('form1:pswdPswd');
                            var digestField = document.getElementById('form1:hiddenDigestedPswd');
                            var shaString = hex_sha1(pswdField.value);
                            pswdField.value = '';
                            digestField.value=shaString;
                            alert(shaString); //This for testing only
                            return false;
                        }
                    </script>

....... followed later by..... <input type="button" value="Click Here!" onclick="digestPswd();" /> Any help would be appreaciated.

Thanks,

Roger L.

Recommended Answers

All 2 Replies

Why don't you use this tag, like everybody else:

<form method="post" action="" name="" >
   <input type="password" name="password">
</form>

Doesn't that send the password in plain text to the server?
My DB stores passwords that have been hashed using SHA1. I would like to implement a means to hash the password in the client using SHA1, before the the form is posted.

BY the way, the button1 element is just there for testing. Ulitimatley, I would will make the call to function as part of the forms submit button onClick event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.