Rails Devise, how to unencrypt a password?

前端 未结 4 1020
醉梦人生
醉梦人生 2021-01-02 21:28

in rails 3 devise, a user record has an encrypted_password and a password_salt.

How in the console, can I obtain a user\'s password? How to unencrypt?

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 22:02

    Devise by default uses the BCrypt algorithm, which AFAIK is not decrypt-able. If you need to be able to decrypt passwords, you need to use a different algorithm such as the AES.

    There is a gem which extends AES support for Devise.

    Note: I have answered this question in a purely academic interest. It would be recommended you continue to use BCrypt. I encourage you to exercise severe caution, since managing passwords is risky business.

提交回复
热议问题