Rails Devise, how to decrypt a password?

in rails 3, the user record has encrypted_material and password_salt.

How can I get the user password in the console? How to decrypt?

+5
source share
4 answers

When developing, the default algorithm is BCrypt, which AFAIK is not able to decrypt. If you need to decrypt passwords, you need to use a different algorithm, such as AES .

There is a gem that extends AES support for Devise.

. . , BCrypt. , - .

+11

Devise BCrypt. encrypted_password USERS .

- : http://www.bcrypt-generator.com/

+2

, : , , ( - ). , . .

0
source
class User < ActiveRecord::Base

  devise :database_authenticatable...

  def verify_password?(password)
    encryptor_class = Devise::Encryptors.const_get(Devise.encryptor.to_s.classify)
    encryptor_digest = encryptor_class.digest(password, Devise.stretches, self.password_salt, Devise.pepper)
    encryptor_digest == self.encrypted_password
  end
end
0
source

All Articles