As a rule, it is incorrect to store a user password that can be used for plain text.
It is usually stored as a salt hash of either MD5 or SHA1.
So, you have a random salt, save it in the user table, and then you get a hash pass and salt, for example:
$hash = md5(md5(salt) + pass)
I would recommend against keeping a pass that can be returned, the only way I recommend you save is with a one-way hash.
However, there are some encryption schemes that you can use, such as RSA encrytion. Thus, your application will encrypt the password of the user that he receives from the end user using your public key, and when you need to decrypt it, do it using your private key. There really is a very limited application for storing the key in this way (for example, to automatically log in to another site) and, as a rule, disapproving.
source share