ruby on rails - want to encrypt password like devise gem and check in db -
how encrypt password through devise gem manually? there gem this?
password coming form web service , want encrypt , check in db
devise internally uses bcrypt gem encryption. bcrypt
class user < activerecord::base before_save :encrypt_password validates_confirmation_of :password validates_presence_of :password, :on => :create def encrypt_password if password.present? self.password_salt = bcrypt::engine.generate_salt self.password_hash = bcrypt::engine.hash_secret(password,password_salt) end end end
try this.
Comments
Post a Comment