Reputation: 1753
How to encrypt password through devise gem manually? is there any gem for this?
Password is coming form web service and i want to encrypt it and check in my db
Upvotes: 0
Views: 977
Reputation: 991
Devise internally uses Bcrypt gem to do 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.
Upvotes: 1