Suppose I entered ABC as password; its hash is like $S$DNcgO9.CUWosQrms0/CqWvLIUFikmoczZ42n9bL6wxiH1OhIQbd5, which is stored in the user table. I need to retrieve the plain password.
How can I achieve this?
Suppose I entered ABC as password; its hash is like $S$DNcgO9.CUWosQrms0/CqWvLIUFikmoczZ42n9bL6wxiH1OhIQbd5, which is stored in the user table. I need to retrieve the plain password.
How can I achieve this?
The short answer is you cannot. Drupal is using a SHA-512
which is a cryptographic hash function. SHA-512
is one way which means it is not possible to get the original data back.
You can check this api. https://api.drupal.org/api/drupal/includes%21password.inc/function/user_check_password/7.x and this https://api.drupal.org/api/drupal/includes%21password.inc/function/user_hash_password/7.x.
You cannot get the password from its hash, if not by brute force. That is why the hash is saved in the database: Even if somebody would be able to read the database content, they would not get any password from the database.
There isn't any need to give the user their password; if they forgot their password, Drupal has a way to let them set a new one, which is done by sending an email with a link.
Directly disclosing passwords from the site is a bad idea. Are you sure the user asking for the password is the legitimate person, and not somebody that is trying to get access to somebody else's account?
To how many users do you want to give their passwords? If you have very less users on your site, then you can reset password for each user from admin panel (from edit user page) and send updated password to each user.
You will not get password from the database as password are saved using SHA-512 (cryptographic hash function).