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

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -