Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password hashing at client browser

What's the best way to hash the user password at the client browser, before sending it to the web server, so that only the hash goes out, not the plain-text password?

EDIT: assuming HTTP is used (not HTTPS)

like image 290
Andy Avatar asked Nov 21 '09 07:11

Andy


People also ask

Should password be hashed on client side?

Hashing passwords makes it possible to use them for authentication, while making it hard to reconstruct the original password. Hashing passwords on the client may be beneficial: even though it does not protect against attackers, it does protect against accidental mistakes.

Is hashing done client side or server side?

Server side hashing is more common than client side hashing, as read access to databases seems to be a more common compromise, but this doesn't mean you should ignore MITM attacks that gain read access to network traffic.

How do passwords pass securely from server to client?

This is usually overcome by encrypting the communication between the user and the server. The most common form of encryption is the Transport Layer Security (TLS) standard or the older SSL standard (Secure Socket Layer).

What is client hash?

Client Hash is a lightweight library implementing the most extended cryptographic hash function algorithms in pure JavaScript (ES5 compliant). The goal is to provide a dependency-free, fast and reliable solution for hash algorithms for client-side actions.


3 Answers

Use javascript to calculate the hash. See this for an example on how to calculate SHA-1 hashes in JS.

Beware that if you make yourself dependant on Javascript, your system will fail as soon as someone has JS disabled. You should use HTTPS if this is a concern to you, which has its own setbacks (e.g. certificates cost money if you want them to be immediately accepted by browsers.)

like image 115
ty812 Avatar answered Oct 18 '22 03:10

ty812


Try using this jQuery encryption plugin. Out of curiosity, what's wrong with using SSL/HTTPS and encrypting at the server side?

like image 34
Traveling Tech Guy Avatar answered Oct 18 '22 03:10

Traveling Tech Guy


Not all people have JavaScript enabled in their browsers and even the idea of sending hashes on a plain-text channel I think is not secure enough.

I would recommend you to consider a SSL secured connection.

like image 1
Christian C. Salvadó Avatar answered Oct 18 '22 03:10

Christian C. Salvadó