The only thing that can help you is to create a temporary salt for each session, then encrypt the password on the client side, and then decrypting the password using the same salt that was saved on the server side, this approach looks like a unique token that was used to prevent CRSF, because even a man-in-the-middle has captured a password that he cannot decrypt.
Finally, you need to create another (different algorithm) to save the password in the database, the conceptual idea above is to provide a password between the client and server.
explanation:
Client → Request → Server
Server -> Reply (sending a unique salt can be used with JavaScript like session_id ()) -> client
Client -> Executing JavaScript -> Password Encryption Using Unique Salt
Client -> POST -> Server
Server → password decryption with saved salt → password retrieval
I hope someone corrects me if the idea above is wrong!
Note: AES can be used for both JS and PHP
Salt = Key
Available tools:
AES Advanced Encryption Standard
jsaes: AES in JavaScript
PHP AES DEC / ENC
phpAES
user1646111
source share