I am in a bit of confusion as we have been asked to AES encrypt passwords before sending it to the server. The whole website communicates over HTTPS with the server and uses secure cookies.

AFAIK, HTTPS uses an SSL 128 bit encryption (could be 256 bit, not sure) and this happens at the Transportation Layer. I am assuming as long as the client is not compromised, an attack at Presentation or Application layer is not possible. Thus, once SSL encrypted, I think information will reach the server safely.

So is it still required to encrypt valuable information such as passwords at the client side before sending it to the server?

  • 8
    This has been covered many times before e.g. this and this
    – paj28
    Aug 10, 2016 at 8:40
  • @paj28 I searched with keywords 'HTTPS' , 'encryption' and 'password' before posting this question. Aug 10, 2016 at 8:52
  • 2
    Keep in mind that there are so many HTTPS certificates around that some prime collision is likely to happens, but breaking HTTPS certificates GCD is not something common humans would do, so unless you run a site with ultra secure requirements (military, government, bank) you are fine with A CORRECTLY CONFIGURED HTTPS. Aug 10, 2016 at 9:47
  • 2
    Also, HTTPS allows many protocols (SSL1-3/TLS1.0-1.2) and a large number of ciper suites. The exact cipher used is based on agreement between the client and server. It can be weaker than "128 bit".
    – billc.cn
    Aug 10, 2016 at 12:25

4 Answers 4


Encrypting the password before sending it over HTTPS probably doesn't add more security.

Consider: how is the password encrypted by the sender, and how is it decrypted by the receiver?
If you use a symmetrical algorithm, then how did they negotiate the key? If the key is built into the client, anyone who reverse engineers the client will have access to it.
If you use an asymmetrical (i.e. public-key) algorithm, either to encrypt the key or to negotiate a key for a symmetrical algorithm... you're just doing the same that SSL/TLS is doing for you.

Simply use the highest available version of TLS, with the longest key that your server and clients both have available.

Just for completeness: HTTPS uses SSL/TLS. It originally stood for "HTTP over SSL". Nowadays SSL has been found vulnerable, and you should use its successor TLS.

On the server, you make a hash of (password + salt value). There is a lot of information about how to do safe web-based authentication on Stack Overflow's Definitive Guide to Form-Based Website Authentication.

  • 4
    And just for completeness: Passwords need to be cryptographically protected (not encrypted - e.g. bcrypt) before storage, but that is on the server.
    – AviD
    Aug 10, 2016 at 7:19
  • Does this also mean that there is no need to take a hash of input password and compare against the existing ones in database ? Aug 10, 2016 at 7:33
  • @FlyingGambit That's what you do on the server. You also add salt. I've updated my answer, added a link to Stack Overflow's canonical question about website authentication. Aug 10, 2016 at 7:37
  • No need to discuss any encryption details here. The script used to do the encryption is downloaded via HTTPS. If the HTTPS connection is compromised, the attacker can do anything to the password.
    – billc.cn
    Aug 10, 2016 at 12:28
  • 1

Generalising Frederics answer a bit, there could be a need for encryption of the password at the client if the solution does not use HTTPS end-to-end in the credentials data flow.

Some reasons for not using end-to-end HTTPS are:

  • The HTTPS is terminated at some edge server such as a load balancer or reverse proxy, with plain HTTP between the edge server and the final destination server (Frederics situation would be another example of this).
  • The requests are held at rest at some point in their flow, such as in a message queue for load-levelling

In this case, it could make sense to use message level encryption as you describe.


I have seen such requests from clients who were sold the concept of end-to-end encryption for the passwords.

The setup is the following: there is a dedicated server that validates the passwords and other credentials, and nothing else. The server that hosts the application delegates the authentication to that dedicated server, passing the encrypted credentials.

The HTTPS encryption stops at the application server, but the encrypted credentials are still protected until they reach the authentication server.

Now I'm not sure that makes a whole lot of sense, but as I said I've met clients who request such a thing.


Usually a software architecture consists of a frontend, a middleware (for business logic) and a backend (e.g. database) and all those components process the password. An attacker who has compromised one of those components would be able to intercept passwords.

One mitigation is to encrypt passwords. With public key encryption the following scenario would be possible:

  • the backend creates a public and private key
  • the public key will be included into the form where the user enters his password
  • when the user submits the form a JavaScript code encrypts the password using the public key
  • the frontend receives the encrypted password, sends it to the middleware which sends it to the backend
  • only the backend can decrypt it

Thus, an attacker who compromised the frontend or middleware cannot see the plaintext password.

  • If its an offline attack, cant the attacker just get the password field value from console ? Aug 10, 2016 at 8:16
  • I'm talking about an attacker in your internal network who could for example attach to processes on servers to intercept data. This is not an offline attack as the attacker uses your system to get the passwords.
    – DanielE
    Aug 10, 2016 at 9:57

Not the answer you're looking for? Browse other questions tagged .