• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Changing A Form Field Value On Submit

 
Jason Ferguson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to make my application login slightly more secure by hashing a password via javascript to sha-256 BEFORE sending it to the server.

So, the user puts their password into a password field:

<input type="password" name="userPassword" id="userPassword" />

On submit, I need to run the sha_256 function on userPassword, then submit. So, I need a javascript function to fire off on the form's onSumit action.

This is probably simple, but I'm not sure. Can someone help?

Jason
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like this should do the trick:
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep,

what you can do is just have the type of input just be a button instead of a submit, then you can just assign your hashfunction to the onclick method of that button input.

then after you hash and all that stuff in your function, just use the .submit() function like so.



it's either .submit or .submit() can't remember off hand.

Justin Fox
 
Jason Ferguson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. I hadn't done anything like this in awhile, and had totally forgotten how to do it.

Unfortunately, it doesn't solve the debate whether hashing on the client side and passing the hash makes the app any more secure.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd probably use SSL to make a secure connection instead of using hashs. If the password seems worth securing, then so should the actual data.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic