I am working on a sign in form using jQuery / CodeIgniter and was wondering if it would be possible to do something like so:
- When the user clicks
Sign Init sends a request via AJAX to get a value key (set using CodeIgniter flashdata). - Once it has the key, it hashes the password with SHA256, then encodes the hashed password with the key from the AJAX request.
- After this, it sends the username / encoded and hashed password to the server, where it is then decoded, salted, re-hashed and checked against the stored password in the database.
Obviously, since the AJAX request will be sent almost at the same time as the login request, there will be a check for this too before attempting to log the user in.
Basically, I want to know if there is a consistent way to do key-based encoding/decoding in JavaScript and PHP, and if so, how to do it.